feat: v3.2

This commit is contained in:
2023-08-13 22:58:59 +08:00
parent 56f6ccd777
commit 7f6b8ab819
7 changed files with 37 additions and 14 deletions

View File

@@ -32,6 +32,7 @@ impl Command for CommandImpl {
.arg(Arg::with_name("value-hex").long("value-hex").short("x").takes_value(true).help("Value(hex), for encrypt"))
.arg(Arg::with_name("value-base64").long("value-base64").short("b").takes_value(true).help("Value(base64), for encrypt"))
.arg(Arg::with_name("yubikey-challenge").long("yubikey-challenge").short("c").takes_value(true).help("Yubikey challenge"))
.arg(Arg::with_name("comment").long("comment").takes_value(true).help("Comment"))
.arg(Arg::with_name("force-write").long("force-write").short("F").help("Force write value"))
}
@@ -151,12 +152,14 @@ async fn do_write(_arg_matches: &ArgMatches<'_>, sub_arg_matches: &ArgMatches<'_
let value_hex = sub_arg_matches.value_of("value-hex");
let value_base64 = sub_arg_matches.value_of("value-base64");
let force_write = sub_arg_matches.is_present("force-write");
let comment = sub_arg_matches.value_of("comment");
let body = if let Some(value) = value {
json!({ "name": key, "force_write": force_write, "value": json!({"value": value}) })
json!({ "name": key, "force_write": force_write, "comment": comment, "value": json!({"value": value}) })
} else if let Some(value_hex) = value_hex {
json!({ "name": key, "force_write": force_write, "value": json!({"value_hex": value_hex}) })
json!({ "name": key, "force_write": force_write, "comment": comment, "value": json!({"value_hex": value_hex}) })
} else if let Some(value_base64) = value_base64 {
json!({ "name": key, "force_write": force_write, "value": json!({"value_base64": value_base64}) })
json!({ "name": key, "force_write": force_write, "comment": comment, "value": json!({"value_base64": value_base64}) })
} else {
return simple_error!("Require one of value, value-hex, value-base64");
};