// WARN: This file is auto generated by flood-tide-gen const OPTIONS_TEXT: &str = r"Options: -f, --format select output style -r, --radix display numbers in octal, decimal or hex -t, --totals display total size (berkeley only) -D, --demangle demangle function name (-fF only) --src-file display source file name (-fF only) --sort sort column. N is 0,1,2,3. (-fF only) -H, --help display this help and exit -V, --version output version information and exit "; #[repr(u8)] #[derive(Debug, PartialEq, Eq)] enum CmdOp { Format, Radix, Totals, Demangle, SrcFile, Sort, 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;8] = [ Opt { sho: b'D', lon: "demangle", has: Arg::No, num: CmdOp::Demangle.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'r', lon: "radix", has: Arg::Yes, num: CmdOp::Radix.to(), }, Opt { sho: 0u8, lon: "sort", has: Arg::Yes, num: CmdOp::Sort.to(), }, Opt { sho: 0u8, lon: "src-file", has: Arg::No, num: CmdOp::SrcFile.to(), }, Opt { sho: b't', lon: "totals", has: Arg::No, num: CmdOp::Totals.to(), }, Opt { sho: b'V', lon: "version", has: Arg::No, num: CmdOp::Version.to(), }, ]; #[rustfmt::skip] const OPT_ARY_SHO_IDX: [(u8,usize);6] = [ (b'D',0),(b'H',2),(b'V',7),(b'f',1),(b'r',3),(b't',6),]; #[derive(Debug, PartialEq, Eq)] pub struct SubCmdOptConf<'a> { pub parent: &'a CmdOptConf, pub prog_name: String, // pub opt_format: FormatStyle, pub opt_radix: RadixStyle, pub flg_totals: bool, pub flg_demangle: bool, pub flg_src_file: bool, pub opt_sort: u8, 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_format: Default::default(), opt_radix: Default::default(), flg_totals: Default::default(), flg_demangle: Default::default(), flg_src_file: Default::default(), opt_sort: 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_u8(nv: &NameVal<'_>) -> Result { match nv.val { Some(x) => match x.parse::() { Ok(d) => Ok(d), 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())), } } fn value_to_format_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())), } } 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())), } }