From 8f361c37704194914d3f095050e1c8b7d51cb3bd Mon Sep 17 00:00:00 2001 From: Nora Widdecke Date: Wed, 8 Jun 2022 11:00:58 +0200 Subject: sq: Adapt verify command to clap3's derive style. - This is part of the effort of moving to clap3's derive API and profit from the added type safety. --- sq/src/sq.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'sq') diff --git a/sq/src/sq.rs b/sq/src/sq.rs index a794f8a9..ae3a8cd1 100644 --- a/sq/src/sq.rs +++ b/sq/src/sq.rs @@ -553,19 +553,21 @@ fn main() -> Result<()> { } }, Some(("verify", m)) => { - let mut input = open_or_stdin(m.value_of("input"))?; + use clap::FromArgMatches; + let command = sq_cli::VerifyCommand::from_arg_matches(m)?; + + // TODO: Fix interface of open_or_stdin, create_or_stdout_safe, etc. + let mut input = open_or_stdin(command.input.as_deref())?; let mut output = - config.create_or_stdout_safe(m.value_of("output"))?; - let mut detached = if let Some(f) = m.value_of("detached") { + config.create_or_stdout_safe(command.output.as_deref())?; + let mut detached = if let Some(f) = command.detached { Some(File::open(f)?) } else { None }; - let signatures: usize = - m.value_of("signatures").expect("has a default").parse()?; - let certs = m.values_of("sender-cert-file") - .map(load_certs) - .unwrap_or_else(|| Ok(vec![]))?; + let signatures = command.signatures; + // TODO ugly adaptation to load_certs' signature, fix later + let certs = load_certs(command.sender_cert_file.iter().map(|s| s.as_ref()))?; commands::verify(config, &mut input, detached.as_mut().map(|r| r as &mut (dyn io::Read + Sync + Send)), &mut output, signatures, certs)?; -- cgit v1.2.3