summaryrefslogtreecommitdiff
path: root/cli/flags.rs
diff options
context:
space:
mode:
authorJacob Gee-Clarke <jacob@jacobgc.me>2020-07-06 04:58:23 +0100
committerGitHub <noreply@github.com>2020-07-05 23:58:23 -0400
commit79610378d3001757b7664a0cefa8fc99125f5a18 (patch)
tree229630a006359ae01f5422c8fcd02e3790731c89 /cli/flags.rs
parentc3c13351a9f26f2209b51b8ded5e8f2a1ad86e94 (diff)
feat(cli): Added support for the --cert flag with 'deno upgrade' (#6609)
Diffstat (limited to 'cli/flags.rs')
-rw-r--r--cli/flags.rs28
1 files changed, 27 insertions, 1 deletions
diff --git a/cli/flags.rs b/cli/flags.rs
index bbd23148b..e0b8d807c 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -70,6 +70,7 @@ pub enum DenoSubcommand {
dry_run: bool,
force: bool,
version: Option<String>,
+ ca_file: Option<String>,
},
}
@@ -563,13 +564,17 @@ fn test_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
}
fn upgrade_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
+ ca_file_arg_parse(flags, matches);
+
let dry_run = matches.is_present("dry-run");
let force = matches.is_present("force");
let version = matches.value_of("version").map(|s| s.to_string());
+ let ca_file = matches.value_of("cert").map(|s| s.to_string());
flags.subcommand = DenoSubcommand::Upgrade {
dry_run,
force,
version,
+ ca_file,
};
}
@@ -862,6 +867,7 @@ and is used to replace the current executable.",
.short("f")
.help("Replace current exe even if not out-of-date"),
)
+ .arg(ca_file_arg())
}
fn doc_subcommand<'a, 'b>() -> App<'a, 'b> {
@@ -1393,7 +1399,8 @@ mod tests {
subcommand: DenoSubcommand::Upgrade {
force: true,
dry_run: true,
- version: None
+ version: None,
+ ca_file: None
},
..Flags::default()
}
@@ -2620,6 +2627,25 @@ mod tests {
}
#[test]
+ fn upgrade_with_ca_file() {
+ let r =
+ flags_from_vec_safe(svec!["deno", "upgrade", "--cert", "example.crt"]);
+ assert_eq!(
+ r.unwrap(),
+ Flags {
+ subcommand: DenoSubcommand::Upgrade {
+ force: false,
+ dry_run: false,
+ version: None,
+ ca_file: Some("example.crt".to_owned()),
+ },
+ ca_file: Some("example.crt".to_owned()),
+ ..Flags::default()
+ }
+ );
+ }
+
+ #[test]
fn eval_with_inspect() {
let r = flags_from_vec_safe(svec![
"deno",