| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- use std::path::PathBuf;
- use clap::Parser;
- use clap::ValueEnum;
- #[derive(Parser, Debug)]
- #[command(
- version,
- about,
- long_about = "A compression utility for utf-8 encoded text, \
- using only basic canonical huffman encoding."
- )]
- pub struct Args {
- /// The input file to be (de)compressed.
- pub input_file: PathBuf,
- /// The optional output file for the resulting (de)compressed output.
- pub output_file: Option<PathBuf>,
- /// Whether to compress or extract.
- #[arg(short, value_enum)]
- pub mode: Option<Mode>,
- }
- #[derive(Clone, Copy, Debug, ValueEnum, Default)]
- pub enum Mode {
- /// Extract
- X,
- #[default]
- /// Compress
- C,
- }
- impl From<Mode> for clap::builder::OsStr {
- fn from(val: Mode) -> Self {
- match val {
- Mode::X => clap::builder::OsStr::from("x"),
- Mode::C => clap::builder::OsStr::from("c"),
- }
- }
- }
|