diff options
author | Ry Dahl <ry@tinyclouds.org> | 2019-11-03 10:39:27 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-03 10:39:27 -0500 |
commit | 86b3ac5108e2893091475a0318fcba6c14e19140 (patch) | |
tree | 11c977dcad8271cc047e5707130b0811507370c4 /cli/flags.rs | |
parent | 65e91796720ea68d69ac7f925a8f239aee8fb19e (diff) |
feat: lockfiles (#3231)
Use --lock-write=lock.json or --lock-check=lock.json on the command
line.
Diffstat (limited to 'cli/flags.rs')
-rw-r--r-- | cli/flags.rs | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/cli/flags.rs b/cli/flags.rs index ca9887351..c6bb0a20f 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -60,6 +60,9 @@ pub struct DenoFlags { pub v8_flags: Option<Vec<String>>, // Use tokio::runtime::current_thread pub current_thread: bool, + + pub lock: Option<String>, + pub lock_write: bool, } static ENV_VARIABLES_HELP: &str = "ENVIRONMENT VARIABLES: @@ -131,7 +134,7 @@ pub fn create_cli_app<'a, 'b>() -> App<'a, 'b> { .global_settings(&[AppSettings::ColorNever, AppSettings::UnifiedHelpMessage, AppSettings::DisableVersion]) .settings(&[AppSettings::AllowExternalSubcommands]) .after_help(ENV_VARIABLES_HELP) - .long_about("A secure runtime for JavaScript and TypeScript built with V8, Rust, and Tokio. + .long_about("A secure JavaScript and TypeScript runtime Docs: https://deno.land/manual.html Modules: https://deno.land/x/ @@ -143,7 +146,7 @@ To run the REPL: To execute a sandboxed script: - deno https://deno.land/welcome.ts + deno https://deno.land/std/examples/welcome.ts To evaluate code from the command line: @@ -224,6 +227,18 @@ Examples: https://github.com/WICG/import-maps#the-import-map", }) .global(true), ).arg( + Arg::with_name("lock") + .long("lock") + .value_name("FILE") + .help("Check the specified lock file") + .takes_value(true) + .global(true), + ).arg( + Arg::with_name("lock-write") + .long("lock-write") + .help("Write lock file. Use with --lock.") + .global(true), + ).arg( Arg::with_name("v8-options") .long("v8-options") .help("Print V8 command line options") @@ -634,6 +649,13 @@ pub fn parse_flags( } } } + if matches.is_present("lock") { + let lockfile = matches.value_of("lock").unwrap(); + flags.lock = Some(lockfile.to_string()); + } + if matches.is_present("lock-write") { + flags.lock_write = true; + } flags = parse_run_args(flags, matches); // flags specific to "run" subcommand @@ -1890,4 +1912,24 @@ mod tests { assert_eq!(subcommand, DenoSubcommand::Run); assert_eq!(argv, svec!["deno", "script.ts"]) } + + #[test] + fn test_flags_from_vec_38() { + let (flags, subcommand, argv) = flags_from_vec(svec![ + "deno", + "--lock-write", + "--lock=lock.json", + "script.ts" + ]); + assert_eq!( + flags, + DenoFlags { + lock_write: true, + lock: Some("lock.json".to_string()), + ..DenoFlags::default() + } + ); + assert_eq!(subcommand, DenoSubcommand::Run); + assert_eq!(argv, svec!["deno", "script.ts"]) + } } |