diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2024-08-08 09:46:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-08 15:46:10 +0200 |
commit | 1d5927aaf2b932046c8052e6ba08d9cc3a066651 (patch) | |
tree | 92324a723ee7b1cecf860c21b759d530546bc49b /cli/args/flags.rs | |
parent | ab8802f49b882651b1bb7057aca79d13e077ef50 (diff) |
feat: support short flags for permissions (#24883)
This commit adds short CLI flags for following permission flags:
- "-R" for "--allow-read"
- "-W" for "--allow-write"
- "-E" for "--allow-env"
- "-N" for "--allow-net"
- "-S" for "--allow-sys"
---------
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/args/flags.rs')
-rw-r--r-- | cli/args/flags.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs index d7aa005b8..81773b06a 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -3137,6 +3137,7 @@ fn permission_args(app: Command) -> Command { .arg( Arg::new("allow-read") .long("allow-read") + .short('R') .num_args(0..) .use_value_delimiter(true) .require_equals(true) @@ -3159,6 +3160,7 @@ fn permission_args(app: Command) -> Command { .arg( Arg::new("allow-write") .long("allow-write") + .short('W') .num_args(0..) .use_value_delimiter(true) .require_equals(true) @@ -3181,6 +3183,7 @@ fn permission_args(app: Command) -> Command { .arg( Arg::new("allow-net") .long("allow-net") + .short('N') .num_args(0..) .use_value_delimiter(true) .require_equals(true) @@ -3202,6 +3205,7 @@ fn permission_args(app: Command) -> Command { .arg( Arg::new("allow-env") .long("allow-env") + .short('E') .num_args(0..) .use_value_delimiter(true) .require_equals(true) @@ -3242,6 +3246,7 @@ fn permission_args(app: Command) -> Command { .arg( Arg::new("allow-sys") .long("allow-sys") + .short('S') .num_args(0..) .use_value_delimiter(true) .require_equals(true) @@ -5697,6 +5702,26 @@ mod tests { } #[test] + fn short_permission_flags() { + let r = flags_from_vec(svec!["deno", "run", "-RW", "gist.ts"]); + assert_eq!( + r.unwrap(), + Flags { + subcommand: DenoSubcommand::Run(RunFlags::new_default( + "gist.ts".to_string() + )), + permissions: PermissionFlags { + allow_read: Some(vec![]), + allow_write: Some(vec![]), + ..Default::default() + }, + code_cache_enabled: true, + ..Flags::default() + } + ); + } + + #[test] fn deny_read() { let r = flags_from_vec(svec!["deno", "run", "--deny-read", "gist.ts"]); assert_eq!( |