diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/flags.rs | 64 |
1 files changed, 61 insertions, 3 deletions
diff --git a/cli/flags.rs b/cli/flags.rs index 0e1110bba..2ec1be021 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -350,7 +350,21 @@ Demonstrates breaking the input up by space delimiter instead of by lines: .long_about( "Automatically downloads deno_installer dependencies on first run. - deno install file_server https://deno.land/std/http/file_server.ts --allow-net --allow-read", +Default installation directory is $HOME/.deno/bin and it must be added to the path manually. + + deno install file_server https://deno.land/std/http/file_server.ts --allow-net --allow-read + + deno install colors https://deno.land/std/examples/colors.ts + +To change installation directory use -d/--dir flag + + deno install -d /usr/local/bin file_server https://deno.land/std/http/file_server.ts --allow-net --allow-read", + ).arg( + Arg::with_name("dir") + .long("dir") + .short("d") + .help("Installation directory (defaults to $HOME/.deno/bin)") + .takes_value(true) ).arg( Arg::with_name("exe_name") .help("Executable name") @@ -509,7 +523,7 @@ fn parse_run_args(mut flags: DenoFlags, matches: &ArgMatches) -> DenoFlags { /// Used for `deno fmt <files>...` subcommand const PRETTIER_URL: &str = "https://deno.land/std@v0.7.0/prettier/main.ts"; /// Used for `deno install...` subcommand -const INSTALLER_URL: &str = "https://deno.land/std@1679ba/installer/mod.ts"; +const INSTALLER_URL: &str = "https://deno.land/std@b13441f/installer/mod.ts"; /// These are currently handled subcommands. /// There is no "Help" subcommand because it's handled by `clap::App` itself. @@ -617,10 +631,18 @@ pub fn flags_from_vec( flags.allow_run = true; argv.push(INSTALLER_URL.to_string()); + if install_match.is_present("dir") { + let install_dir = install_match.value_of("dir").unwrap(); + argv.push("--dir".to_string()); + argv.push(install_dir.to_string()); + } + let exe_name: &str = install_match.value_of("exe_name").unwrap(); + argv.push(exe_name.to_string()); + match install_match.subcommand() { (script_url, Some(script_match)) => { - argv.extend(vec![exe_name.to_string(), script_url.to_string()]); + argv.push(script_url.to_string()); if script_match.is_present("") { let flags: Vec<String> = script_match .values_of("") @@ -1322,5 +1344,41 @@ mod tests { "--allow-read" ] ); + + let (flags, subcommand, argv) = flags_from_vec(svec![ + "deno", + "install", + "-d", + "/usr/local/bin", + "file_server", + "https://deno.land/std/http/file_server.ts", + "--allow-net", + "--allow-read" + ]); + assert_eq!( + flags, + DenoFlags { + allow_write: true, + allow_net: true, + allow_read: true, + allow_env: true, + allow_run: true, + ..DenoFlags::default() + } + ); + assert_eq!(subcommand, DenoSubcommand::Install); + assert_eq!( + argv, + svec![ + "deno", + INSTALLER_URL, + "--dir", + "/usr/local/bin", + "file_server", + "https://deno.land/std/http/file_server.ts", + "--allow-net", + "--allow-read" + ] + ); } } |