aki-xcat 0.1.35

concatenate files that are plain, gzip, xz and zstd.
Documentation
// 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 <num>   read from pipe <num> [unimplemented]

  -H, --help        display this help and exit
  -V, --version     display version information and exit
  -X <x-options>    x options. try -X help
";

#[repr(u8)]
#[derive(Debug, PartialEq, Eq)]
enum CmdOp {
    Number,
    FileName,
    PathName,
    PipeIn,
    Help,
    Version,
    UcX,
}

impl std::convert::From<u8> 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: b'X', lon: "",              has: Arg::Yes, num: CmdOp::UcX.to(), },
    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);6] = [
(b'H',2),(b'V',6),(b'X',0),(b'f',1),(b'n',3),(b'p',5),];

#[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 opt_uc_x: Vec<OptUcXParam>,
    //
    pub arg_params: Vec<String>,
}

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<String, OptParseError> {
    match nv.val {
        Some(x) => Ok(x.to_string()),
        None => Err(OptParseError::missing_option_argument(&nv.opt.lon_or_sho())),
    }
}

fn value_to_opt_uc_x_param(nv: &NameVal<'_>) -> Result<OptUcXParam, OptParseError> {
    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())),
    }
}