Improve chooser invocation error message (#772)
Since the chooser is invoked via the shell, print out the full shell command line, instead of just the chooser.
This commit is contained in:
parent
b66a979c08
commit
122c351eba
@ -571,7 +571,9 @@ impl Config {
|
|||||||
Err(error) => {
|
Err(error) => {
|
||||||
if self.verbosity.loud() {
|
if self.verbosity.loud() {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"Chooser `{}` invocation failed: {}",
|
"Chooser `{} {} {}` invocation failed: {}",
|
||||||
|
justfile.settings.shell_binary(self),
|
||||||
|
justfile.settings.shell_arguments(self).join(" "),
|
||||||
chooser.to_string_lossy(),
|
chooser.to_string_lossy(),
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
|
@ -15,20 +15,30 @@ impl<'src> Settings<'src> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn shell_command(&self, config: &Config) -> Command {
|
pub(crate) fn shell_command(&self, config: &Config) -> Command {
|
||||||
if let (Some(shell), false) = (&self.shell, config.shell_present) {
|
let mut cmd = Command::new(self.shell_binary(config));
|
||||||
let mut cmd = Command::new(shell.command.cooked.as_ref());
|
|
||||||
|
|
||||||
for argument in &shell.arguments {
|
cmd.args(self.shell_arguments(config));
|
||||||
cmd.arg(argument.cooked.as_ref());
|
|
||||||
|
cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd
|
pub(crate) fn shell_binary<'a>(&'a self, config: &'a Config) -> &'a str {
|
||||||
|
if let (Some(shell), false) = (&self.shell, config.shell_present) {
|
||||||
|
shell.command.cooked.as_ref()
|
||||||
} else {
|
} else {
|
||||||
let mut cmd = Command::new(&config.shell);
|
&config.shell
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cmd.args(&config.shell_args);
|
pub(crate) fn shell_arguments<'a>(&'a self, config: &'a Config) -> Vec<&'a str> {
|
||||||
|
if let (Some(shell), false) = (&self.shell, config.shell_present) {
|
||||||
cmd
|
shell
|
||||||
|
.arguments
|
||||||
|
.iter()
|
||||||
|
.map(|argument| argument.cooked.as_ref())
|
||||||
|
.collect()
|
||||||
|
} else {
|
||||||
|
config.shell_args.iter().map(String::as_ref).collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user