use clap::Parser;

#[derive(Parser, Debug, Default, Clone)]
#[command(name = "lesser", version, about = "A less-compatible pager")]
pub struct Flags {
    #[arg(short = 'R', long = "raw-control-chars")]
    pub raw_control_chars: bool,

    #[arg(short = 'F', long = "quit-if-one-screen")]
    pub quit_if_one_screen: bool,

    #[arg(short = 'X', long = "no-init")]
    pub no_init: bool,

    #[arg(short = 'S', long = "chop-long-lines")]
    pub chop_long_lines: bool,

    #[arg(short = 'K', long = "quit-on-intr")]
    pub quit_on_intr: bool,

    pub files: Vec<String>,
}

impl Flags {
    pub fn merge_env_bundle(&mut self, bundle: &str) {
        for ch in bundle.chars() {
            match ch {
                'R' => self.raw_control_chars = true,
                'F' => self.quit_if_one_screen = true,
                'X' => self.no_init = true,
                'S' => self.chop_long_lines = true,
                'K' => self.quit_on_intr = true,
                _ => {}
            }
        }
    }
}
