diff options
author | Geert-Jan Zwiers <geertjanzwiers@protonmail.com> | 2023-01-09 13:29:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-09 13:29:43 +0100 |
commit | fa175d8cdaeff37daa68cadea5b0e59fa794a0c2 (patch) | |
tree | 726fbd88298841f746084d1b451a9c48a12266d5 /cli/args/flags.rs | |
parent | c41d4ff90e09b63bd1894052352a5acba57b1704 (diff) |
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.
Diffstat (limited to 'cli/args/flags.rs')
-rw-r--r-- | cli/args/flags.rs | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs index b5753c00b..c3e2b8cfb 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", ) @@ -5531,6 +5531,23 @@ mod tests { } #[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::<Vec<_>>(); + // 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] let r = flags_from_vec(svec!["deno", "test", "--unstable", "--trace-ops", "--no-run", "--filter", "- foo", "--coverage=cov", "--location", "https:foo", "--allow-net", "--allow-none", "dir1/", "dir2/", "--", "arg1", "arg2"]); |