commit_wizard/engine/models/runtime/
mode.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
4#[serde(rename_all = "kebab-case")]
5pub enum RunMode {
6 #[default]
7 Interactive,
8 NonInteractive,
9 Ci,
10}
11
12impl RunMode {
13 pub fn from_flags(ci: bool, non_interactive: bool) -> Self {
14 if ci {
15 Self::Ci
16 } else if non_interactive {
17 Self::NonInteractive
18 } else {
19 Self::Interactive
20 }
21 }
22
23 pub fn allows_prompts(self) -> bool {
24 matches!(self, Self::Interactive)
25 }
26
27 pub fn is_strict(self) -> bool {
28 matches!(self, Self::Ci | Self::NonInteractive)
29 }
30}