-
Notifications
You must be signed in to change notification settings - Fork 1
/
shells.rs
48 lines (44 loc) · 1.3 KB
/
shells.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use serde::Deserialize;
use serde::Serialize;
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub enum SupportedShell {
Sh,
Zsh,
Bash,
Fish,
PowerShell,
WinCmd,
}
impl SupportedShell {
pub fn as_program_str(&self) -> &'static str {
match self {
SupportedShell::Sh => "sh",
SupportedShell::Zsh => "zsh",
SupportedShell::Bash => "bash",
SupportedShell::Fish => "fish",
SupportedShell::PowerShell => "powershell",
SupportedShell::WinCmd => "cmd.exe",
}
}
pub fn as_dflt_arg_str(&self) -> &'static str {
match self {
SupportedShell::Sh => "-c",
SupportedShell::Zsh => "-c",
SupportedShell::Bash => "-c",
SupportedShell::Fish => "-c",
SupportedShell::PowerShell => "-command",
SupportedShell::WinCmd => "/C",
}
}
pub fn from_str(shell: &str) -> SupportedShell {
match shell {
"sh" => SupportedShell::Sh,
"zsh" => SupportedShell::Zsh,
"bash" => SupportedShell::Bash,
"fish" => SupportedShell::Fish,
"powershell" => SupportedShell::PowerShell,
"cmd" => SupportedShell::WinCmd,
_ => SupportedShell::Sh,
}
}
}