aboutsummaryrefslogtreecommitdiff
path: root/src/args.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/args.rs')
-rw-r--r--src/args.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/args.rs b/src/args.rs
index f54025e..758af8c 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -16,6 +16,9 @@ pub struct Args {
/// Disables the cache for all secrets.
#[structopt(long, global = true)]
pub no_cache: bool,
+ /// Selects the output format.
+ #[structopt(long, global = true, possible_values = &OutputFormat::all_str())]
+ pub output_format: Option<OutputFormat>,
#[structopt(subcommand)]
pub cmd: Command,
}
@@ -68,6 +71,26 @@ impl<'de> serde::Deserialize<'de> for DeviceModel {
}
}
+Enum! {
+ /// The format for the nitrocli output.
+ OutputFormat, [
+ Text => "text",
+ ]
+}
+
+impl<'de> serde::Deserialize<'de> for OutputFormat {
+ fn deserialize<D>(deserializer: D) -> Result<OutputFormat, D::Error>
+ where
+ D: serde::Deserializer<'de>,
+ {
+ use serde::de::Error as _;
+ use std::str::FromStr as _;
+
+ let s = String::deserialize(deserializer)?;
+ OutputFormat::from_str(&s).map_err(D::Error::custom)
+ }
+}
+
Command! {
/// A top-level command for nitrocli.
Command, [