summaryrefslogtreecommitdiffstats
path: root/sq/src/sq.rs
diff options
context:
space:
mode:
Diffstat (limited to 'sq/src/sq.rs')
-rw-r--r--sq/src/sq.rs37
1 files changed, 20 insertions, 17 deletions
diff --git a/sq/src/sq.rs b/sq/src/sq.rs
index eba6a771..f08513c0 100644
--- a/sq/src/sq.rs
+++ b/sq/src/sq.rs
@@ -488,18 +488,20 @@ fn main() -> Result<()> {
})?;
},
Some(("sign", m)) => {
- let mut input = open_or_stdin(m.value_of("input"))?;
- let output = m.value_of("output");
- let detached = m.is_present("detached");
- let binary = m.is_present("binary");
- let append = m.is_present("append");
- let notarize = m.is_present("notarize");
- let private_key_store = m.value_of("private-key-store");
- let secrets = m.values_of("secret-key-file")
- .map(load_certs)
- .unwrap_or_else(|| Ok(vec![]))?;
- let time = if let Some(time) = m.value_of("time") {
- Some(parse_iso8601(time, chrono::NaiveTime::from_hms(0, 0, 0))
+ use clap::FromArgMatches;
+ let command = sq_cli::SignCommand::from_arg_matches(m)?;
+
+ let mut input = open_or_stdin(command.input.as_deref())?;
+ let output = command.output.as_deref();
+ let detached = command.detached;
+ let binary = command.binary;
+ let append = command.append;
+ let notarize = command.notarize;
+ let private_key_store = command.private_key_store.as_deref();
+ let secrets =
+ load_certs(command.secret_key_file.iter().map(|s| s.as_ref()))?;
+ let time = if let Some(time) = command.time {
+ Some(parse_iso8601(&time, chrono::NaiveTime::from_hms(0, 0, 0))
.context(format!("Bad value passed to --time: {:?}",
time))?.into())
} else {
@@ -508,7 +510,8 @@ fn main() -> Result<()> {
// Each --notation takes two values. The iterator
// returns them one at a time, however.
let mut notations: Vec<(bool, NotationData)> = Vec::new();
- if let Some(mut n) = m.values_of("notation") {
+ if let Some(n) = command.notation {
+ let mut n = n.iter();
while let Some(name) = n.next() {
let value = n.next().unwrap();
@@ -516,7 +519,7 @@ fn main() -> Result<()> {
if let Some(name) = name.strip_prefix('!') {
(true, name)
} else {
- (false, name)
+ (false, name.as_str())
};
notations.push(
@@ -527,12 +530,12 @@ fn main() -> Result<()> {
}
}
- if let Some(merge) = m.value_of("merge") {
+ if let Some(merge) = command.merge {
let output = config.create_or_stdout_pgp(output, binary,
armor::Kind::Message)?;
- let mut input2 = open_or_stdin(Some(merge))?;
+ let mut input2 = open_or_stdin(Some(&merge))?;
commands::merge_signatures(&mut input, &mut input2, output)?;
- } else if m.is_present("clearsign") {
+ } else if command.clearsign {
let output = config.create_or_stdout_safe(output)?;
commands::sign::clearsign(config, private_key_store, input, output, secrets,
time, &notations)?;