hwatch icon indicating copy to clipboard operation
hwatch copied to clipboard

Allow diff modes specification directly from flag

Open rcontreras-te opened this issue 1 year ago • 1 comments

Right now it seems you can enable the diff mode to be turned on via --differences but you can't specify which mode to use therefore you have to manually use the d key (or 1-3) to switch to the desired diff-mode.

I'd like to suggest that this be enabled directly via the flag, for example

$ hwatch --differences=[1-3] COMMAND ...

or possibly using a keyword,

$ hwatch --differences=[watch,line,word] COMMAND ...

rcontreras-te avatar Aug 03 '23 16:08 rcontreras-te

Looks good!

blacknon avatar Mar 04 '24 07:03 blacknon

PoC code for realizing options. Need to upgrade the version of clap.

use clap::{Command, Arg};
use clap::builder::ArgPredicate;

fn main() {
    let matches = Command::new("My-App")
        .arg(
            Arg::new("hogehoge")
                .long("hogehoge")
                .value_parser(["always", "auto", "never"])
                .num_args(0..=1)
                .default_missing_value("auto")
                .default_value_ifs([("hogehoge",ArgPredicate::IsPresent,None)])
        )
        .get_matches();

    // --hogehoge オプションが指定されているかをチェック
    if matches.contains_id("hogehoge") {
        let selected_value = matches.get_one::<String>("hogehoge").unwrap();
        println!("Selected value: {}", selected_value);
    } else {
        println!("Option --hogehoge not specified");

    }
}

blacknon avatar Mar 23 '24 13:03 blacknon

Closed because it was applied in version 0.3.12.

blacknon avatar Apr 07 '24 07:04 blacknon