// WARN: This file is auto generated by flood-tide-gen const OPTIONS_TEXT: &str = r"Options: -a, --all output the all statistics of text -b, --bytes output the byte counts -c, --chars output the unicode character counts -l, --lines output the line counts -m, --max-line-bytes output the maximum byte counts of line -w, --words output the word counts --locale locale of number format: en, fr, ... posix -?, --query display available names of locale and exit -H, --help display this help and exit -V, --version display version information and exit "; #[repr(u8)] #[derive(Debug, PartialEq, Eq)] enum CmdOp { All, Bytes, Chars, Lines, MaxLineBytes, Words, Locale, Query, 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;10] = [ Opt { sho: b'a', lon: "all", has: Arg::No, num: CmdOp::All.to(), }, Opt { sho: b'b', lon: "bytes", has: Arg::No, num: CmdOp::Bytes.to(), }, Opt { sho: b'c', lon: "chars", has: Arg::No, num: CmdOp::Chars.to(), }, Opt { sho: b'H', lon: "help", has: Arg::No, num: CmdOp::Help.to(), }, Opt { sho: b'l', lon: "lines", has: Arg::No, num: CmdOp::Lines.to(), }, Opt { sho: 0u8, lon: "locale", has: Arg::Yes, num: CmdOp::Locale.to(), }, Opt { sho: b'm', lon: "max-line-bytes",has: Arg::No, num: CmdOp::MaxLineBytes.to(), }, Opt { sho: b'?', lon: "query", has: Arg::Yes, num: CmdOp::Query.to(), }, Opt { sho: b'V', lon: "version", has: Arg::No, num: CmdOp::Version.to(), }, Opt { sho: b'w', lon: "words", has: Arg::No, num: CmdOp::Words.to(), }, ]; #[rustfmt::skip] const OPT_ARY_SHO_IDX: [(u8,usize);9] = [ (b'?',7),(b'H',3),(b'V',8),(b'a',0),(b'b',1),(b'c',2),(b'l',4),(b'm',6),(b'w',9),]; #[derive(Debug, Default, PartialEq, Eq)] pub struct CmdOptConf { pub prog_name: String, // pub flg_all: bool, pub flg_bytes: bool, pub flg_chars: bool, pub flg_lines: bool, pub flg_max_line_bytes: bool, pub flg_words: bool, pub opt_locale: OptLocaleLoc, pub opt_query: Option, 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_locale_loc(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())), } }