summaryrefslogtreecommitdiff
path: root/cli/flags.rs
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2020-02-08 00:49:55 -0800
committerGitHub <noreply@github.com>2020-02-08 09:49:55 +0100
commit619a24390ff15d5ea5e577a4d0391823f94e8592 (patch)
tree25be718dce5df73964b70c7251a345243d87067d /cli/flags.rs
parentf650c3edb3081ac0433b338c0c99418171656dd1 (diff)
install: add --force flag and remove yes/no prompt (#3917)
Diffstat (limited to 'cli/flags.rs')
-rw-r--r--cli/flags.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/cli/flags.rs b/cli/flags.rs
index 897df611c..748a7f95e 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -59,6 +59,7 @@ pub enum DenoSubcommand {
exe_name: String,
module_url: String,
args: Vec<String>,
+ force: bool,
},
Repl,
Run {
@@ -320,6 +321,7 @@ fn install_parse(flags: &mut DenoFlags, matches: &clap::ArgMatches) {
None
};
+ let force = matches.is_present("force");
let exe_name = matches.value_of("exe_name").unwrap().to_string();
let cmd_values = matches.values_of("cmd").unwrap();
let mut cmd_args = vec![];
@@ -336,6 +338,7 @@ fn install_parse(flags: &mut DenoFlags, matches: &clap::ArgMatches) {
exe_name,
module_url,
args,
+ force,
};
}
@@ -580,6 +583,12 @@ fn install_subcommand<'a, 'b>() -> App<'a, 'b> {
.takes_value(true)
.multiple(false))
.arg(
+ Arg::with_name("force")
+ .long("force")
+ .short("f")
+ .help("Forcefully overwrite existing installation")
+ .takes_value(false))
+ .arg(
Arg::with_name("exe_name")
.required(true)
)
@@ -1791,6 +1800,7 @@ mod tests {
exe_name: "deno_colors".to_string(),
module_url: "https://deno.land/std/examples/colors.ts".to_string(),
args: vec![],
+ force: false,
},
..DenoFlags::default()
}
@@ -1815,6 +1825,7 @@ mod tests {
exe_name: "file_server".to_string(),
module_url: "https://deno.land/std/http/file_server.ts".to_string(),
args: vec![],
+ force: false,
},
allow_net: true,
allow_read: true,
@@ -1824,12 +1835,13 @@ mod tests {
}
#[test]
- fn install_with_args_and_dir() {
+ fn install_with_args_and_dir_and_force() {
let r = flags_from_vec_safe(svec![
"deno",
"install",
"-d",
"/usr/local/bin",
+ "-f",
"--allow-net",
"--allow-read",
"file_server",
@@ -1845,6 +1857,7 @@ mod tests {
exe_name: "file_server".to_string(),
module_url: "https://deno.land/std/http/file_server.ts".to_string(),
args: svec!["arg1", "arg2"],
+ force: true,
},
allow_net: true,
allow_read: true,