2019-11-10 23:17:47 -08:00
|
|
|
use crate::common::*;
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub(crate) struct Settings<'src> {
|
|
|
|
pub(crate) shell: Option<setting::Shell<'src>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'src> Settings<'src> {
|
|
|
|
pub(crate) fn new() -> Settings<'src> {
|
|
|
|
Settings { shell: None }
|
|
|
|
}
|
|
|
|
|
2019-11-22 11:33:56 -08:00
|
|
|
pub(crate) fn shell_command(&self, config: &Config) -> Command {
|
|
|
|
if let (Some(shell), false) = (&self.shell, config.shell_present) {
|
2019-11-10 23:17:47 -08:00
|
|
|
let mut cmd = Command::new(shell.command.cooked.as_ref());
|
|
|
|
|
|
|
|
for argument in &shell.arguments {
|
|
|
|
cmd.arg(argument.cooked.as_ref());
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd
|
|
|
|
} else {
|
2019-11-22 11:33:56 -08:00
|
|
|
let mut cmd = Command::new(&config.shell);
|
2019-11-10 23:17:47 -08:00
|
|
|
|
2019-11-22 11:33:56 -08:00
|
|
|
cmd.args(&config.shell_args);
|
2019-11-10 23:17:47 -08:00
|
|
|
|
|
|
|
cmd
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|