// WARN: This file is auto generated by flood-tide-gen const OPTIONS_TEXT: &str = r"Options: -r, --radix display numbers in octal, decimal or hex --no-escape no escape string --src-file display source file name -H, --help display this help and exit -V, --version output version information and exit "; #[repr(u8)] #[derive(Debug, PartialEq, Eq)] enum CmdOp { Radix, NoEscape, SrcFile, 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;5] = [ Opt { sho: b'H', lon: "help", has: Arg::No, num: CmdOp::Help.to(), }, Opt { sho: 0u8, lon: "no-escape", has: Arg::No, num: CmdOp::NoEscape.to(), }, Opt { sho: b'r', lon: "radix", has: Arg::Yes, num: CmdOp::Radix.to(), }, Opt { sho: 0u8, lon: "src-file", has: Arg::No, num: CmdOp::SrcFile.to(), }, Opt { sho: b'V', lon: "version", has: Arg::No, num: CmdOp::Version.to(), }, ]; #[rustfmt::skip] const OPT_ARY_SHO_IDX: [(u8,usize);3] = [ (b'H',0),(b'V',4),(b'r',2),]; #[derive(Debug, PartialEq, Eq)] pub struct SubCmdOptConf<'a> { pub parent: &'a CmdOptConf, pub prog_name: String, // pub opt_radix: RadixStyle, pub flg_no_escape: bool, pub flg_src_file: bool, pub flg_help: bool, pub flg_version: bool, // pub arg_params: Vec, } impl<'a> SubCmdOptConf<'a> { pub fn new(a_parent: &'a CmdOptConf, a_prog_name: String) -> SubCmdOptConf<'a> { SubCmdOptConf { parent: a_parent, prog_name: a_prog_name, // opt_radix: Default::default(), flg_no_escape: Default::default(), flg_src_file: Default::default(), flg_help: Default::default(), flg_version: Default::default(), // arg_params: Vec::new(), } } } impl<'a> flood_tide::HelpVersion for SubCmdOptConf<'a> { fn is_help(&self) -> bool { self.flg_help } fn is_version(&self) -> bool { self.flg_version } } fn value_to_radix_style(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())), } }