Skip to content

Commit f60065d

Browse files
committed
✨ feat(mq-run): reject --allow-all combined with individual --allow-* flags, add -a short form
conflicts_with_all rejects --allow-all alongside --allow-net/read/write/run/env at parse time with a clear clap error, instead of silently overriding their values. Also add -a as a short form: unlike the other --allow-* flags (which stay long-only), --allow-all mirrors Deno's -A/--allow-all convention — -A itself is unavailable here since it's already --aggregate.
1 parent 2f28d8d commit f60065d

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

crates/mq-run/src/cli.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,14 @@ struct InputArgs {
412412
#[arg(long = "allow-env", num_args = 0.., require_equals = true, value_delimiter = ',', value_name = "NAME")]
413413
allow_env: Option<Vec<String>>,
414414

415-
/// Grant every sandboxed permission at once (read/write/net/run/env), overriding
416-
/// any allowlist given to the individual --allow-* flags. Disabled by default.
417-
#[arg(long = "allow-all", default_value_t = false)]
415+
/// Grant every sandboxed permission at once (read/write/net/run/env). Disabled by
416+
/// default. Cannot be combined with the individual --allow-* flags above.
417+
#[arg(
418+
short = 'a',
419+
long = "allow-all",
420+
default_value_t = false,
421+
conflicts_with_all = ["allow_net", "allow_read", "allow_write", "allow_run", "allow_env"]
422+
)]
418423
allow_all: bool,
419424
}
420425

@@ -1886,6 +1891,18 @@ mod tests {
18861891
);
18871892
}
18881893

1894+
#[rstest]
1895+
#[case(&["mq", "--allow-all", "--allow-read=/tmp", "self"])]
1896+
#[case(&["mq", "--allow-all", "--allow-write=/tmp", "self"])]
1897+
#[case(&["mq", "--allow-all", "--allow-run", "self"])]
1898+
#[case(&["mq", "--allow-all", "--allow-env", "self"])]
1899+
fn test_allow_all_conflicts_with_individual_allow_flags(#[case] args: &[&str]) {
1900+
assert!(
1901+
Cli::try_parse_from(args).is_err(),
1902+
"--allow-all should conflict with individual --allow-* flags"
1903+
);
1904+
}
1905+
18891906
#[rstest]
18901907
#[case(0.0)]
18911908
#[case(-1.0)]

0 commit comments

Comments
 (0)