diff options
author | Ry Dahl <ry@tinyclouds.org> | 2020-01-15 19:21:35 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-15 19:21:35 -0500 |
commit | a4dde552de8fced4cfdff7f0127b51e1d2eabca5 (patch) | |
tree | 6590ed26f995522746948601b281987ece5c8ff3 /cli/flags.rs | |
parent | 3eab20ce42458fced42dcd031958b07113322e0a (diff) |
Revert "feat(flags): script arguments come after '--'" (#3681)
Due to complaints about ergonomics and because it breaks shebang on
linux.
This reverts commit 2d5457df15d8c4a81362bb2d185b5c6013faa1d8.
BREAKING CHANGE
Diffstat (limited to 'cli/flags.rs')
-rw-r--r-- | cli/flags.rs | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/cli/flags.rs b/cli/flags.rs index 6d6129c7a..f2a3ffc36 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -485,7 +485,6 @@ fn run_test_args_parse(flags: &mut DenoFlags, matches: &clap::ArgMatches) { fn run_parse(flags: &mut DenoFlags, matches: &clap::ArgMatches) { flags.subcommand = DenoSubcommand::Run; script_arg_parse(flags, matches); - args_parse(flags, matches); run_test_args_parse(flags, matches); } @@ -925,7 +924,6 @@ fn run_subcommand<'a, 'b>() -> App<'a, 'b> { run_test_args(SubCommand::with_name("run")) .setting(AppSettings::TrailingVarArg) .arg(script_arg()) - .arg(args_arg()) .about("Run a program given a filename or url to the source code") .long_about( "Run a program given a filename or url to the source code. @@ -945,11 +943,7 @@ With only permission to read from disk and listen to network With only permission to read whitelist files from disk - deno run --allow-read=/etc https://deno.land/std/http/file_server.ts - -Any arguments that should be passed to the script should be prefixed by '--' - - deno run -A https://deno.land/std/examples/cat.ts -- /etc/passwd", + deno run --allow-read=/etc https://deno.land/std/http/file_server.ts", ) } @@ -994,26 +988,15 @@ _test.js and executes them. } fn script_arg<'a, 'b>() -> Arg<'a, 'b> { - Arg::with_name("script").help("script").value_name("SCRIPT") -} - -fn script_arg_parse(flags: &mut DenoFlags, matches: &ArgMatches) { - if let Some(script_value) = matches.value_of("script") { - debug_assert!(flags.argv.len() == 1); - flags.argv.push(String::from(script_value)); - } -} - -fn args_arg<'a, 'b>() -> Arg<'a, 'b> { - Arg::with_name("script_args") - .raw(true) + Arg::with_name("script_arg") + .multiple(true) .help("script args") - .value_name("SCRIPT_ARGS") + .value_name("SCRIPT_ARG") } -fn args_parse(flags: &mut DenoFlags, matches: &ArgMatches) { - if let Some(values) = matches.values_of("script_args") { - for v in values { +fn script_arg_parse(flags: &mut DenoFlags, matches: &ArgMatches) { + if let Some(script_values) = matches.values_of("script_arg") { + for v in script_values { flags.argv.push(String::from(v)); } } @@ -1341,7 +1324,6 @@ mod tests { "run", "--allow-net", "gist.ts", - "--", "--title", "X" ]); @@ -1424,7 +1406,7 @@ mod tests { r.unwrap(), DenoFlags { subcommand: DenoSubcommand::Run, - argv: svec!["deno", "script.ts", "-D", "--allow-net"], + argv: svec!["deno", "script.ts", "--", "-D", "--allow-net"], allow_write: true, ..DenoFlags::default() } |