From dd6950e5fe13b04409e38f1e51b043747c4562aa Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Tue, 18 Oct 2022 17:50:24 +0300 Subject: [PATCH] add command line options to specify output format, version In this change, these have no effect, but they will have soon. Very soon. Sponsored-by: NLnet Foundation; NGI Assure --- tools/src/bin/opgpcard/cli.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/src/bin/opgpcard/cli.rs b/tools/src/bin/opgpcard/cli.rs index df53ea2..0b1334e 100644 --- a/tools/src/bin/opgpcard/cli.rs +++ b/tools/src/bin/opgpcard/cli.rs @@ -4,6 +4,12 @@ use clap::{AppSettings, Parser}; use std::path::PathBuf; +use crate::{OutputFormat, OutputVersion}; + +pub const DEFAULT_OUTPUT_VERSION: &str = "1.0.0"; +pub const OUTPUT_VERSIONS: &[OutputVersion] = + &[OutputVersion::new(0, 0, 0), OutputVersion::new(1, 0, 0)]; + #[derive(Parser, Debug)] #[clap( name = "opgpcard", @@ -13,12 +19,24 @@ use std::path::PathBuf; about = "A tool for inspecting and configuring OpenPGP cards." )] pub struct Cli { + /// Produce output in the chosen format. + #[clap(long, value_enum, default_value = "text")] + pub output_format: OutputFormat, + + /// Pick output version to use, for non-textual formats. + #[clap(long, default_value = DEFAULT_OUTPUT_VERSION)] + pub output_version: OutputVersion, + #[clap(subcommand)] pub cmd: Command, } #[derive(Parser, Debug)] pub enum Command { + /// Show all output versions that are supported. Mark the + /// currently chosen one with a star. + OutputVersions {}, + /// Enumerate available OpenPGP cards List {},