// WARN: This file is auto generated by flood-tide-gen const OPTIONS_TEXT: &str = r"Options: -n, --number output line number for each lines -f, --file-name output file name for each lines --path-name output path name for each lines -p, --pipe-in read from pipe [unimplemented] -H, --help display this help and exit -V, --version display version information and exit "; #[repr(u8)] #[derive(Debug, PartialEq, Eq)] enum CmdOp { Number, FileName, PathName, PipeIn, 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;6] = [ Opt { sho: b'f', lon: "file-name", has: Arg::No, num: CmdOp::FileName.to(), }, Opt { sho: b'H', lon: "help", has: Arg::No, num: CmdOp::Help.to(), }, Opt { sho: b'n', lon: "number", has: Arg::No, num: CmdOp::Number.to(), }, Opt { sho: 0u8, lon: "path-name", has: Arg::No, num: CmdOp::PathName.to(), }, Opt { sho: b'p', lon: "pipe-in", has: Arg::Yes, num: CmdOp::PipeIn.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',5),(b'f',0),(b'n',2),(b'p',4),]; #[derive(Debug, Default, PartialEq, Eq)] pub struct CmdOptConf { pub prog_name: String, // pub flg_number: bool, pub flg_file_name: bool, pub flg_path_name: bool, pub opt_pipe_in: String, 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())), } }