aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/comp/flags.rs
diff options
context:
space:
mode:
authorWeicao-CatilGrass <1992414357@qq.com>2026-05-09 13:21:01 +0800
committerWeicao-CatilGrass <1992414357@qq.com>2026-05-09 13:21:01 +0800
commitc0a29ccd2cd56e75c2b422b3cd9ca65d76a554da (patch)
tree26ce74a8f1138bed899d7896b48f1d5706ab96d4 /mingling_core/src/comp/flags.rs
parentc08ea7d8474335cadf13a2a7e45ca497fe375d90 (diff)
Move `comp` module from `asset` to crate root
Diffstat (limited to 'mingling_core/src/comp/flags.rs')
-rw-r--r--mingling_core/src/comp/flags.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/mingling_core/src/comp/flags.rs b/mingling_core/src/comp/flags.rs
new file mode 100644
index 0000000..452126b
--- /dev/null
+++ b/mingling_core/src/comp/flags.rs
@@ -0,0 +1,45 @@
+use just_fmt::snake_case;
+
+/// Represents the shell environment for which the output format is intended.
+///
+/// This enum defines the supported shell types that can be used for
+/// generating shell-specific command syntax, scripts, or completions.
+#[derive(Default, Debug, Clone)]
+#[cfg_attr(feature = "general_renderer", derive(serde::Serialize))]
+pub enum ShellFlag {
+ /// Represents the Bash shell.
+ #[default]
+ Bash,
+ /// Represents the Zsh shell.
+ Zsh,
+ /// Represents the Fish shell.
+ Fish,
+ /// Represents PowerShell.
+ Powershell,
+ /// A custom or unsupported shell type, identified by the provided string.
+ 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,
+ "pwsh" | "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,
+ }
+ }
+}