// WARN: This file is auto generated by flood-tide-gen const OPTIONS_TEXT: &str = r"Options: --stage1 stage1 regular expression --cap-num1 stage1 cap numbers. conma sep. --stage2 stage2 regular expression --cap-num2 stage2 cap numbers. conma sep. --stage3 stage3 regular expression --cap-num3 stage3 cap numbers. conma sep. --stage4 stage4 regular expression --cap-num4 stage4 cap numbers. conma sep. --stage5 stage5 regular expression --cap-num5 stage5 cap numbers. conma sep. -n, --quiet no output unmach lines --debug debug print --expire-minutes key expire minutes --help-expression display help exp and exit -H, --help display this help and exit -V, --version display version information and exit "; #[repr(u8)] #[derive(Debug, PartialEq, Eq)] enum CmdOp { Stage1, CapNum1, Stage2, CapNum2, Stage3, CapNum3, Stage4, CapNum4, Stage5, CapNum5, Quiet, Debug, ExpireMinutes, HelpExpression, 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;16] = [ Opt { sho: 0u8, lon: "cap-num1", has: Arg::Yes, num: CmdOp::CapNum1.to(), }, Opt { sho: 0u8, lon: "cap-num2", has: Arg::Yes, num: CmdOp::CapNum2.to(), }, Opt { sho: 0u8, lon: "cap-num3", has: Arg::Yes, num: CmdOp::CapNum3.to(), }, Opt { sho: 0u8, lon: "cap-num4", has: Arg::Yes, num: CmdOp::CapNum4.to(), }, Opt { sho: 0u8, lon: "cap-num5", has: Arg::Yes, num: CmdOp::CapNum5.to(), }, Opt { sho: 0u8, lon: "debug", has: Arg::No, num: CmdOp::Debug.to(), }, Opt { sho: 0u8, lon: "expire-minutes",has: Arg::Yes, num: CmdOp::ExpireMinutes.to(), }, Opt { sho: b'H', lon: "help", has: Arg::No, num: CmdOp::Help.to(), }, Opt { sho: 0u8, lon: "help-expression",has: Arg::No, num: CmdOp::HelpExpression.to(), }, Opt { sho: b'n', lon: "quiet", has: Arg::No, num: CmdOp::Quiet.to(), }, Opt { sho: 0u8, lon: "stage1", has: Arg::Yes, num: CmdOp::Stage1.to(), }, Opt { sho: 0u8, lon: "stage2", has: Arg::Yes, num: CmdOp::Stage2.to(), }, Opt { sho: 0u8, lon: "stage3", has: Arg::Yes, num: CmdOp::Stage3.to(), }, Opt { sho: 0u8, lon: "stage4", has: Arg::Yes, num: CmdOp::Stage4.to(), }, Opt { sho: 0u8, lon: "stage5", has: Arg::Yes, num: CmdOp::Stage5.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',7),(b'V',15),(b'n',9),]; #[derive(Debug, Default, PartialEq, Eq)] pub struct CmdOptConf { pub prog_name: String, // pub opt_stage1: String, pub opt_cap_num1: OptCapNumNums, pub opt_stage2: String, pub opt_cap_num2: OptCapNumNums, pub opt_stage3: String, pub opt_cap_num3: OptCapNumNums, pub opt_stage4: String, pub opt_cap_num4: OptCapNumNums, pub opt_stage5: String, pub opt_cap_num5: OptCapNumNums, pub flg_quiet: bool, pub flg_debug: bool, pub opt_expire_minutes: i64, pub flg_help_expression: 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_i64(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_opt_cap_num_nums(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())), } }