Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow diff modes specification directly from flag #98

Closed
rcontreras-te opened this issue Aug 3, 2023 · 3 comments
Closed

Allow diff modes specification directly from flag #98

rcontreras-te opened this issue Aug 3, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@rcontreras-te
Copy link

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 ...
@blacknon
Copy link
Owner

blacknon commented Mar 4, 2024

Looks good!

@blacknon blacknon self-assigned this Mar 4, 2024
@blacknon blacknon added the enhancement New feature or request label Mar 4, 2024
@blacknon
Copy link
Owner

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 added a commit that referenced this issue Mar 27, 2024
@blacknon blacknon mentioned this issue Apr 7, 2024
@blacknon
Copy link
Owner

blacknon commented Apr 7, 2024

Closed because it was applied in version 0.3.12.

@blacknon blacknon closed this as completed Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants