mirror of
https://github.com/watchexec/watchexec.git
synced 2024-10-01 07:31:35 +02:00
Re-add --kill flag for compatibility
--kill translates to --signal SIGKILL
This commit is contained in:
parent
627f828b3c
commit
4763de3790
24
src/cli.rs
24
src/cli.rs
@ -33,8 +33,7 @@ pub fn clear_screen() {
|
|||||||
#[allow(unknown_lints)]
|
#[allow(unknown_lints)]
|
||||||
#[allow(or_fun_call)]
|
#[allow(or_fun_call)]
|
||||||
pub fn get_args() -> Args {
|
pub fn get_args() -> Args {
|
||||||
let args =
|
let args = App::new("watchexec")
|
||||||
App::new("watchexec")
|
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about("Execute commands when watched files change")
|
.about("Execute commands when watched files change")
|
||||||
.arg(Arg::with_name("command")
|
.arg(Arg::with_name("command")
|
||||||
@ -68,6 +67,10 @@ pub fn get_args() -> Args {
|
|||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.number_of_values(1)
|
.number_of_values(1)
|
||||||
.value_name("signal"))
|
.value_name("signal"))
|
||||||
|
.arg(Arg::with_name("kill")
|
||||||
|
.help("Send SIGKILL to child processes (deprecated, use -s SIGKILL instead)")
|
||||||
|
.short("k")
|
||||||
|
.long("kill"))
|
||||||
.arg(Arg::with_name("debug")
|
.arg(Arg::with_name("debug")
|
||||||
.help("Print debugging messages to stderr")
|
.help("Print debugging messages to stderr")
|
||||||
.short("d")
|
.short("d")
|
||||||
@ -102,9 +105,16 @@ pub fn get_args() -> Args {
|
|||||||
.arg(Arg::with_name("once").short("1").hidden(true))
|
.arg(Arg::with_name("once").short("1").hidden(true))
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
let cmd = values_t!(args.values_of("command"), String).unwrap().join(" ");
|
let cmd = values_t!(args.values_of("command"), String)
|
||||||
|
.unwrap()
|
||||||
|
.join(" ");
|
||||||
let paths = values_t!(args.values_of("path"), String).unwrap_or(vec![String::from(".")]);
|
let paths = values_t!(args.values_of("path"), String).unwrap_or(vec![String::from(".")]);
|
||||||
let signal = args.value_of("signal").map(str::to_string); // Convert Option<&str> to Option<String>
|
|
||||||
|
// Treat --kill as --signal SIGKILL (for compatibility with older syntax)
|
||||||
|
let signal = match args.is_present("kill") {
|
||||||
|
true => Some("SIGKILL".to_string()),
|
||||||
|
false => args.value_of("signal").map(str::to_string), // Convert Option<&str> to Option<String>
|
||||||
|
};
|
||||||
|
|
||||||
let mut filters = values_t!(args.values_of("filter"), String).unwrap_or(vec![]);
|
let mut filters = values_t!(args.values_of("filter"), String).unwrap_or(vec![]);
|
||||||
|
|
||||||
@ -138,6 +148,12 @@ pub fn get_args() -> Args {
|
|||||||
.exit();
|
.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if signal.is_some() && args.is_present("kill") {
|
||||||
|
// TODO: Error::argument_conflict() might be the better fit, usage was unclear, though
|
||||||
|
Error::value_validation_auto(format!("--kill and --signal is ambiguous.\n Hint: Use only '--signal SIGKILL' without --kill"))
|
||||||
|
.exit();
|
||||||
|
}
|
||||||
|
|
||||||
Args {
|
Args {
|
||||||
cmd: cmd,
|
cmd: cmd,
|
||||||
paths: paths,
|
paths: paths,
|
||||||
|
Loading…
Reference in New Issue
Block a user