From fa175d8cdaeff37daa68cadea5b0e59fa794a0c2 Mon Sep 17 00:00:00 2001 From: Geert-Jan Zwiers Date: Mon, 9 Jan 2023 13:29:43 +0100 Subject: [PATCH] fix(cli/args): update value_name of inspect args to resolve broken completions (#17287) This PR updates the name used in `clap::Arg::value_name` for the `--inspect*` flags from `HOST:PORT` to `HOST_AND_PORT` because the former causes an arguments error when using shell completions in the `zsh` shell. --- cli/args/flags.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/cli/args/flags.rs b/cli/args/flags.rs index b5753c00be..c3e2b8cfb2 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -1952,7 +1952,7 @@ fn inspect_args(app: Command) -> Command { .arg( Arg::new("inspect") .long("inspect") - .value_name("HOST:PORT") + .value_name("HOST_AND_PORT") .help("Activate inspector on host:port (default: 127.0.0.1:9229)") .min_values(0) .max_values(1) @@ -1963,7 +1963,7 @@ fn inspect_args(app: Command) -> Command { .arg( Arg::new("inspect-brk") .long("inspect-brk") - .value_name("HOST:PORT") + .value_name("HOST_AND_PORT") .help( "Activate inspector on host:port, wait for debugger to connect and break at the start of user script", ) @@ -1976,7 +1976,7 @@ fn inspect_args(app: Command) -> Command { .arg( Arg::new("inspect-wait") .long("inspect-wait") - .value_name("HOST:PORT") + .value_name("HOST_AND_PORT") .help( "Activate inspector on host:port and wait for debugger to connect before running user code", ) @@ -5530,6 +5530,23 @@ mod tests { assert!(r.is_err(),); } + #[test] + fn test_no_colon_in_value_name() { + let app = + runtime_args(Command::new("test_inspect_completion_value"), true, true); + let inspect_args = app + .get_arguments() + .filter(|arg| arg.get_id() == "inspect") + .collect::>(); + // The value_name cannot have a : otherwise it breaks shell completions for zsh. + let value_name = "HOST_AND_PORT"; + let arg = inspect_args + .iter() + .any(|v| v.get_value_names().unwrap() == [value_name]); + + assert_eq!(arg, true); + } + #[test] fn test_with_flags() { #[rustfmt::skip]