hwatch
hwatch copied to clipboard
Allow diff modes specification directly from flag
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 ...
Looks good!
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");
}
}
Closed because it was applied in version 0.3.12.