// WARN: This file is auto generated by flood-tide-gen const OPTIONS_TEXT: &str = r"Options: -u, --update update mode -s, --symbol expected symbol -o, --output bi5 data into --from proces from --to proces to -H, --help display this help and exit -V, --version display version information and exit "; #[repr(u8)] #[derive(Debug, PartialEq, Eq)] enum CmdOp { Update, Symbol, Output, From, To, 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;7] = [ Opt { sho: 0u8, lon: "from", has: Arg::Yes, num: CmdOp::From.to(), }, Opt { sho: b'H', lon: "help", has: Arg::No, num: CmdOp::Help.to(), }, Opt { sho: b'o', lon: "output", has: Arg::Yes, num: CmdOp::Output.to(), }, Opt { sho: b's', lon: "symbol", has: Arg::Yes, num: CmdOp::Symbol.to(), }, Opt { sho: 0u8, lon: "to", has: Arg::Yes, num: CmdOp::To.to(), }, Opt { sho: b'u', lon: "update", has: Arg::No, num: CmdOp::Update.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',1),(b'V',6),(b'o',2),(b's',3),(b'u',5),]; #[derive(Debug, Default, PartialEq, Eq)] pub struct CmdOptConf { pub prog_name: String, // pub flg_update: bool, pub opt_symbol: String, pub opt_output: String, pub opt_from: Option, pub opt_to: 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_fromto_date(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())), } }