mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
parent
3d19fb493b
commit
ece1e1d5f1
1 changed files with 39 additions and 2 deletions
41
cli/flags.rs
41
cli/flags.rs
|
@ -579,6 +579,18 @@ fn test_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
|||
flags.coverage = true;
|
||||
}
|
||||
|
||||
if matches.is_present("script_arg") {
|
||||
let script_arg: Vec<String> = matches
|
||||
.values_of("script_arg")
|
||||
.unwrap()
|
||||
.map(String::from)
|
||||
.collect();
|
||||
|
||||
for v in script_arg {
|
||||
flags.argv.push(v);
|
||||
}
|
||||
}
|
||||
|
||||
let include = if matches.is_present("files") {
|
||||
let files: Vec<String> = matches
|
||||
.values_of("files")
|
||||
|
@ -1106,7 +1118,10 @@ fn run_subcommand<'a, 'b>() -> App<'a, 'b> {
|
|||
runtime_args(SubCommand::with_name("run"), true)
|
||||
.arg(watch_arg())
|
||||
.setting(AppSettings::TrailingVarArg)
|
||||
.arg(script_arg())
|
||||
.arg(
|
||||
script_arg()
|
||||
.required(true)
|
||||
)
|
||||
.about("Run a program given a filename or url to the module. Use '-' as a filename to read from stdin.")
|
||||
.long_about(
|
||||
"Run a program given a filename or url to the module.
|
||||
|
@ -1131,6 +1146,7 @@ Deno allows specifying the filename '-' to read the file from stdin.
|
|||
|
||||
fn test_subcommand<'a, 'b>() -> App<'a, 'b> {
|
||||
runtime_args(SubCommand::with_name("test"), true)
|
||||
.setting(AppSettings::TrailingVarArg)
|
||||
.arg(
|
||||
Arg::with_name("failfast")
|
||||
.long("failfast")
|
||||
|
@ -1165,6 +1181,7 @@ fn test_subcommand<'a, 'b>() -> App<'a, 'b> {
|
|||
.takes_value(true)
|
||||
.multiple(true),
|
||||
)
|
||||
.arg(script_arg().last(true))
|
||||
.about("Run tests")
|
||||
.long_about(
|
||||
"Run tests using Deno's built-in test runner.
|
||||
|
@ -1182,7 +1199,6 @@ Directory arguments are expanded to all contained files matching the glob
|
|||
fn script_arg<'a, 'b>() -> Arg<'a, 'b> {
|
||||
Arg::with_name("script_arg")
|
||||
.multiple(true)
|
||||
.required(true)
|
||||
.help("Script arg")
|
||||
.value_name("SCRIPT_ARG")
|
||||
}
|
||||
|
@ -2901,6 +2917,27 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_double_hyphen() {
|
||||
let r = flags_from_vec_safe(svec![
|
||||
"deno", "test", "test.ts", "--", "arg1", "arg2"
|
||||
]);
|
||||
assert_eq!(
|
||||
r.unwrap(),
|
||||
Flags {
|
||||
subcommand: DenoSubcommand::Test {
|
||||
fail_fast: false,
|
||||
allow_none: false,
|
||||
quiet: false,
|
||||
filter: None,
|
||||
include: Some(svec!["test.ts"]),
|
||||
},
|
||||
argv: svec!["arg1", "arg2"],
|
||||
..Flags::default()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_with_cafile() {
|
||||
let r = flags_from_vec_safe(svec![
|
||||
|
|
Loading…
Reference in a new issue