@@ -1342,7 +1342,7 @@ pub fn flags_from_vec(args: Vec<OsString>) -> clap::error::Result<Flags> {
13421342 }
13431343
13441344 match subcommand. as_str ( ) {
1345- "add" => add_parse ( & mut flags, & mut m) ,
1345+ "add" => add_parse ( & mut flags, & mut m) ? ,
13461346 "remove" => remove_parse ( & mut flags, & mut m) ,
13471347 "bench" => bench_parse ( & mut flags, & mut m) ?,
13481348 "bundle" => bundle_parse ( & mut flags, & mut m) ,
@@ -1675,6 +1675,7 @@ You can add multiple dependencies at once:
16751675 . action ( ArgAction :: Append ) ,
16761676 )
16771677 . arg ( add_dev_arg ( ) )
1678+ . arg ( allow_scripts_arg ( ) )
16781679 } )
16791680}
16801681
@@ -1717,7 +1718,7 @@ If you specify a directory instead of a file, the path is expanded to all contai
17171718 UnstableArgsConfig :: ResolutionAndRuntime ,
17181719 )
17191720 . defer ( |cmd| {
1720- runtime_args ( cmd, true , false )
1721+ runtime_args ( cmd, true , false , true )
17211722 . arg ( check_arg ( true ) )
17221723 . arg (
17231724 Arg :: new ( "json" )
@@ -1881,7 +1882,7 @@ On the first invocation with deno will download the proper binary and cache it i
18811882 UnstableArgsConfig :: ResolutionAndRuntime ,
18821883 )
18831884 . defer ( |cmd| {
1884- runtime_args ( cmd, true , false )
1885+ runtime_args ( cmd, true , false , true )
18851886 . arg ( check_arg ( true ) )
18861887 . arg (
18871888 Arg :: new ( "include" )
@@ -2202,7 +2203,7 @@ This command has implicit access to all permissions.
22022203 UnstableArgsConfig :: ResolutionAndRuntime ,
22032204 )
22042205 . defer ( |cmd| {
2205- runtime_args ( cmd, false , true )
2206+ runtime_args ( cmd, false , true , true )
22062207 . arg ( check_arg ( false ) )
22072208 . arg ( executable_ext_arg ( ) )
22082209 . arg (
@@ -2501,7 +2502,7 @@ The installation root is determined, in order of precedence:
25012502These must be added to the path manually if required." ) , UnstableArgsConfig :: ResolutionAndRuntime )
25022503 . visible_alias ( "i" )
25032504 . defer ( |cmd| {
2504- permission_args ( runtime_args ( cmd, false , true ) , Some ( "global" ) )
2505+ permission_args ( runtime_args ( cmd, false , true , false ) , Some ( "global" ) )
25052506 . arg ( check_arg ( true ) )
25062507 . arg ( allow_scripts_arg ( ) )
25072508 . arg (
@@ -2767,7 +2768,7 @@ It is especially useful for quick prototyping and checking snippets of code.
27672768
27682769TypeScript is supported, however it is not type-checked, only transpiled."
27692770 ) , UnstableArgsConfig :: ResolutionAndRuntime )
2770- . defer ( |cmd| runtime_args ( cmd, true , true )
2771+ . defer ( |cmd| runtime_args ( cmd, true , true , true )
27712772 . arg ( check_arg ( false ) )
27722773 . arg (
27732774 Arg :: new ( "eval-file" )
@@ -2799,7 +2800,7 @@ TypeScript is supported, however it is not type-checked, only transpiled."
27992800}
28002801
28012802fn run_args ( command : Command , top_level : bool ) -> Command {
2802- runtime_args ( command, true , true )
2803+ runtime_args ( command, true , true , true )
28032804 . arg ( check_arg ( false ) )
28042805 . arg ( watch_arg ( true ) )
28052806 . arg ( hmr_arg ( true ) )
@@ -2855,7 +2856,7 @@ Start a server defined in server.ts:
28552856Start a server defined in server.ts, watching for changes and running on port 5050:
28562857 <p(245)>deno serve --watch --port 5050 server.ts</>
28572858
2858- <y>Read more:</> <c>https://docs.deno.com/go/serve</>" ) , UnstableArgsConfig :: ResolutionAndRuntime ) , true , true )
2859+ <y>Read more:</> <c>https://docs.deno.com/go/serve</>" ) , UnstableArgsConfig :: ResolutionAndRuntime ) , true , true , true )
28592860 . arg (
28602861 Arg :: new ( "port" )
28612862 . long ( "port" )
@@ -2929,7 +2930,7 @@ or <c>**/__tests__/**</>:
29292930 UnstableArgsConfig :: ResolutionAndRuntime
29302931 )
29312932 . defer ( |cmd|
2932- runtime_args ( cmd, true , true )
2933+ runtime_args ( cmd, true , true , true )
29332934 . arg ( check_arg ( true ) )
29342935 . arg (
29352936 Arg :: new ( "ignore" )
@@ -3642,6 +3643,7 @@ fn runtime_args(
36423643 app : Command ,
36433644 include_perms : bool ,
36443645 include_inspector : bool ,
3646+ include_allow_scripts : bool ,
36453647) -> Command {
36463648 let app = compile_args ( app) ;
36473649 let app = if include_perms {
@@ -3654,6 +3656,11 @@ fn runtime_args(
36543656 } else {
36553657 app
36563658 } ;
3659+ let app = if include_allow_scripts {
3660+ app. arg ( allow_scripts_arg ( ) )
3661+ } else {
3662+ app
3663+ } ;
36573664 app
36583665 . arg ( frozen_lockfile_arg ( ) )
36593666 . arg ( cached_only_arg ( ) )
@@ -4235,8 +4242,13 @@ fn allow_scripts_arg_parse(
42354242 Ok ( ( ) )
42364243}
42374244
4238- fn add_parse ( flags : & mut Flags , matches : & mut ArgMatches ) {
4245+ fn add_parse (
4246+ flags : & mut Flags ,
4247+ matches : & mut ArgMatches ,
4248+ ) -> clap:: error:: Result < ( ) > {
4249+ allow_scripts_arg_parse ( flags, matches) ?;
42394250 flags. subcommand = DenoSubcommand :: Add ( add_parse_inner ( matches, None ) ) ;
4251+ Ok ( ( ) )
42404252}
42414253
42424254fn add_parse_inner (
@@ -4262,7 +4274,7 @@ fn bench_parse(
42624274) -> clap:: error:: Result < ( ) > {
42634275 flags. type_check_mode = TypeCheckMode :: Local ;
42644276
4265- runtime_args_parse ( flags, matches, true , false ) ?;
4277+ runtime_args_parse ( flags, matches, true , false , true ) ?;
42664278 ext_arg_parse ( flags, matches) ;
42674279
42684280 // NOTE: `deno bench` always uses `--no-prompt`, tests shouldn't ever do
@@ -4352,7 +4364,7 @@ fn compile_parse(
43524364 matches : & mut ArgMatches ,
43534365) -> clap:: error:: Result < ( ) > {
43544366 flags. type_check_mode = TypeCheckMode :: Local ;
4355- runtime_args_parse ( flags, matches, true , false ) ?;
4367+ runtime_args_parse ( flags, matches, true , false , true ) ?;
43564368
43574369 let mut script = matches. remove_many :: < String > ( "script_arg" ) . unwrap ( ) ;
43584370 let source_file = script. next ( ) . unwrap ( ) ;
@@ -4527,7 +4539,7 @@ fn eval_parse(
45274539 flags : & mut Flags ,
45284540 matches : & mut ArgMatches ,
45294541) -> clap:: error:: Result < ( ) > {
4530- runtime_args_parse ( flags, matches, false , true ) ?;
4542+ runtime_args_parse ( flags, matches, false , true , false ) ?;
45314543 unstable_args_parse ( flags, matches, UnstableArgsConfig :: ResolutionAndRuntime ) ;
45324544 flags. allow_all ( ) ;
45334545
@@ -4620,7 +4632,7 @@ fn install_parse(
46204632 flags : & mut Flags ,
46214633 matches : & mut ArgMatches ,
46224634) -> clap:: error:: Result < ( ) > {
4623- runtime_args_parse ( flags, matches, true , true ) ?;
4635+ runtime_args_parse ( flags, matches, true , true , false ) ?;
46244636
46254637 let global = matches. get_flag ( "global" ) ;
46264638 if global {
@@ -4846,7 +4858,7 @@ fn repl_parse(
48464858 flags : & mut Flags ,
48474859 matches : & mut ArgMatches ,
48484860) -> clap:: error:: Result < ( ) > {
4849- runtime_args_parse ( flags, matches, true , true ) ?;
4861+ runtime_args_parse ( flags, matches, true , true , true ) ?;
48504862 unsafely_ignore_certificate_errors_parse ( flags, matches) ;
48514863
48524864 let eval_files = matches
@@ -4879,7 +4891,7 @@ fn run_parse(
48794891 mut app : Command ,
48804892 bare : bool ,
48814893) -> clap:: error:: Result < ( ) > {
4882- runtime_args_parse ( flags, matches, true , true ) ?;
4894+ runtime_args_parse ( flags, matches, true , true , true ) ?;
48834895 ext_arg_parse ( flags, matches) ;
48844896
48854897 flags. code_cache_enabled = !matches. get_flag ( "no-code-cache" ) ;
@@ -4920,7 +4932,7 @@ fn serve_parse(
49204932
49214933 let worker_count = parallel_arg_parse ( matches) . map ( |v| v. get ( ) ) ;
49224934
4923- runtime_args_parse ( flags, matches, true , true ) ?;
4935+ runtime_args_parse ( flags, matches, true , true , true ) ?;
49244936 // If the user didn't pass --allow-net, add this port to the network
49254937 // allowlist. If the host is 0.0.0.0, we add :{port} and allow the same network perms
49264938 // as if it was passed to --allow-net directly.
@@ -5015,7 +5027,7 @@ fn test_parse(
50155027 matches : & mut ArgMatches ,
50165028) -> clap:: error:: Result < ( ) > {
50175029 flags. type_check_mode = TypeCheckMode :: Local ;
5018- runtime_args_parse ( flags, matches, true , true ) ?;
5030+ runtime_args_parse ( flags, matches, true , true , true ) ?;
50195031 ext_arg_parse ( flags, matches) ;
50205032
50215033 // NOTE: `deno test` always uses `--no-prompt`, tests shouldn't ever do
@@ -5380,6 +5392,7 @@ fn runtime_args_parse(
53805392 matches : & mut ArgMatches ,
53815393 include_perms : bool ,
53825394 include_inspector : bool ,
5395+ include_allow_scripts : bool ,
53835396) -> clap:: error:: Result < ( ) > {
53845397 unstable_args_parse ( flags, matches, UnstableArgsConfig :: ResolutionAndRuntime ) ;
53855398 compile_args_parse ( flags, matches) ?;
@@ -5391,6 +5404,9 @@ fn runtime_args_parse(
53915404 if include_inspector {
53925405 inspect_arg_parse ( flags, matches) ;
53935406 }
5407+ if include_allow_scripts {
5408+ allow_scripts_arg_parse ( flags, matches) ?;
5409+ }
53945410 location_arg_parse ( flags, matches) ;
53955411 v8_flags_arg_parse ( flags, matches) ;
53965412 seed_arg_parse ( flags, matches) ;
@@ -8862,8 +8878,12 @@ mod tests {
88628878
88638879 #[ test]
88648880 fn test_no_colon_in_value_name ( ) {
8865- let app =
8866- runtime_args ( Command :: new ( "test_inspect_completion_value" ) , true , true ) ;
8881+ let app = runtime_args (
8882+ Command :: new ( "test_inspect_completion_value" ) ,
8883+ true ,
8884+ true ,
8885+ false ,
8886+ ) ;
88678887 let inspect_args = app
88688888 . get_arguments ( )
88698889 . filter ( |arg| arg. get_id ( ) == "inspect" )
0 commit comments