From 11f3077b06d2c7dce5dc35876a8bb419cbb642ca Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Sun, 14 Apr 2024 21:47:02 +0300 Subject: [PATCH] args: add more possible values for manpage names Signed-off-by: Manos Pitsidianakis --- meli/src/args.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/meli/src/args.rs b/meli/src/args.rs index 23ca0efa..96c817e3 100644 --- a/meli/src/args.rs +++ b/meli/src/args.rs @@ -74,7 +74,7 @@ pub enum SubCommand { destination_path: Option, }, #[structopt(display_order = 5)] - /// print compile time feature flags of this binary + /// Print compile time feature flags of this binary CompiledWith, /// Print log file location. PrintLogPath, @@ -87,12 +87,16 @@ pub enum SubCommand { #[derive(Debug, StructOpt)] pub struct ManOpt { - #[structopt(default_value = "meli", possible_values=&["meli", "conf", "themes", "meli.7", "guide"], value_name="PAGE", parse(try_from_str = manpages::parse_manpage))] #[cfg(feature = "cli-docs")] + #[cfg_attr(feature = "cli-docs", structopt(default_value = "meli", possible_values=manpages::POSSIBLE_VALUES, value_name="PAGE", parse(try_from_str = manpages::parse_manpage)))] + /// Name of manual page. pub page: manpages::ManPages, /// If true, output text in stdout instead of spawning $PAGER. - #[structopt(long = "no-raw", alias = "no-raw", value_name = "bool")] #[cfg(feature = "cli-docs")] + #[cfg_attr( + feature = "cli-docs", + structopt(long = "no-raw", alias = "no-raw", value_name = "bool") + )] pub no_raw: Option>, } @@ -108,6 +112,19 @@ pub mod manpages { use crate::{Error, Result}; + pub const POSSIBLE_VALUES: &[&str] = &[ + "meli", + "meli.1", + "conf", + "meli.conf", + "meli.conf.5", + "themes", + "meli-themes", + "meli-themes.5", + "guide", + "meli.7", + ]; + pub fn parse_manpage(src: &str) -> Result { match src { "" | "meli" | "meli.1" | "main" => Ok(ManPages::Main),