d0e813cd8b
Add the `--shell-arg` and `--clear-shell-args` flags, which allow setting and clearing arguments to the shell from the command line. This allows full control over the shell from the command line. Additionally, any shell-related arguments on the command line override `set shell := [...]` in the Justfile, which I think will be the behavior that most people expect.
31 lines
673 B
Rust
31 lines
673 B
Rust
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 }
|
|
}
|
|
|
|
pub(crate) fn shell_command(&self, config: &Config) -> Command {
|
|
if let (Some(shell), false) = (&self.shell, config.shell_present) {
|
|
let mut cmd = Command::new(shell.command.cooked.as_ref());
|
|
|
|
for argument in &shell.arguments {
|
|
cmd.arg(argument.cooked.as_ref());
|
|
}
|
|
|
|
cmd
|
|
} else {
|
|
let mut cmd = Command::new(&config.shell);
|
|
|
|
cmd.args(&config.shell_args);
|
|
|
|
cmd
|
|
}
|
|
}
|
|
}
|