shell_exec/
shell.rs

1use strum::{Display, EnumString};
2
3use crate::Argument;
4
5#[derive(Debug, EnumString, Display, Copy, Clone)]
6pub enum Shell {
7    #[strum(serialize = "zsh")]
8    Zsh,
9    #[strum(serialize = "bash")]
10    Bash,
11    #[strum(serialize = "sh")]
12    Sh,
13    #[strum(serialize = "cmd")]
14    Cmd,
15    #[strum(serialize = "powershell")]
16    Powershell,
17    #[strum(serialize = "wsl")]
18    Wsl,
19}
20
21impl Shell {
22    pub fn command_args(&self) -> &[Argument<'static>] {
23        match self {
24            Self::Cmd => &[Argument::Normal("/C")],
25            Self::Powershell => &[Argument::Normal("-Command")],
26            Self::Wsl => &[Argument::Normal("bash"), Argument::Normal("-c")],
27            _ => &[Argument::Normal("-c")],
28        }
29    }
30}
31
32impl Default for Shell {
33    fn default() -> Self {
34        if cfg!(target_os = "windows") {
35            Self::Cmd
36        } else {
37            Self::Bash
38        }
39    }
40}