diff options
Diffstat (limited to 'mingling_core/src/asset/comp/flags.rs')
| -rw-r--r-- | mingling_core/src/asset/comp/flags.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/mingling_core/src/asset/comp/flags.rs b/mingling_core/src/asset/comp/flags.rs new file mode 100644 index 0000000..b432b08 --- /dev/null +++ b/mingling_core/src/asset/comp/flags.rs @@ -0,0 +1,35 @@ +use just_fmt::snake_case; + +#[derive(Default, Debug, Clone)] +pub enum ShellFlag { + #[default] + Bash, + Zsh, + Fish, + Powershell, + Other(String), +} + +impl From<String> for ShellFlag { + fn from(s: String) -> Self { + match s.trim().to_lowercase().as_str() { + "zsh" => ShellFlag::Zsh, + "bash" => ShellFlag::Bash, + "fish" => ShellFlag::Fish, + "pwsl" | "ps1" | "powershell" => ShellFlag::Powershell, + other => ShellFlag::Other(snake_case!(other)), + } + } +} + +impl From<ShellFlag> for String { + fn from(flag: ShellFlag) -> Self { + match flag { + ShellFlag::Zsh => "zsh".to_string(), + ShellFlag::Bash => "bash".to_string(), + ShellFlag::Fish => "fish".to_string(), + ShellFlag::Powershell => "powershell".to_string(), + ShellFlag::Other(s) => s, + } + } +} |
