// WARN: This file is auto generated by flood-tide-gen const OPTIONS_TEXT: &str = r"Options: --color use markers to highlight the matching strings -e, --exp regular expression -f, --format replace format -n, --quiet no output unmach lines -H, --help display this help and exit -V, --version display version information and exit "; #[repr(u8)] #[derive(Debug, PartialEq, Eq)] enum CmdOp { Color, Exp, Format, Quiet, Help, Version, } impl std::convert::From for CmdOp { fn from(value: u8) -> Self { unsafe { std::mem::transmute(value) } } } impl CmdOp { pub const fn to(self) -> OptNum { self as OptNum } } #[rustfmt::skip] const OPT_ARY: [Opt;6] = [ Opt { sho: 0u8, lon: "color", has: Arg::Yes, num: CmdOp::Color.to(), }, Opt { sho: b'e', lon: "exp", has: Arg::Yes, num: CmdOp::Exp.to(), }, Opt { sho: b'f', lon: "format", has: Arg::Yes, num: CmdOp::Format.to(), }, Opt { sho: b'H', lon: "help", has: Arg::No, num: CmdOp::Help.to(), }, Opt { sho: b'n', lon: "quiet", has: Arg::No, num: CmdOp::Quiet.to(), }, Opt { sho: b'V', lon: "version", has: Arg::No, num: CmdOp::Version.to(), }, ]; #[rustfmt::skip] const OPT_ARY_SHO_IDX: [(u8,usize);5] = [ (b'H',3),(b'V',5),(b'e',1),(b'f',2),(b'n',4),]; #[derive(Debug, Default, PartialEq, Eq)] pub struct CmdOptConf { pub prog_name: String, // pub opt_color: OptColorWhen, pub opt_exp: Vec, pub opt_format: Vec, pub flg_quiet: bool, pub flg_help: bool, pub flg_version: bool, // pub arg_params: Vec, } impl flood_tide::HelpVersion for CmdOptConf { fn is_help(&self) -> bool { self.flg_help } fn is_version(&self) -> bool { self.flg_version } } fn value_to_string(nv: &NameVal<'_>) -> Result { match nv.val { Some(x) => Ok(x.to_string()), None => Err(OptParseError::missing_option_argument(&nv.opt.lon_or_sho())), } } fn value_to_opt_color_when(nv: &NameVal<'_>) -> Result { match nv.val { Some(s) => match FromStr::from_str(s) { Ok(x) => Ok(x), Err(err) => Err(OptParseError::invalid_option_argument( &nv.opt.lon_or_sho(), &err.to_string(), )), }, None => Err(OptParseError::missing_option_argument(&nv.opt.lon_or_sho())), } }