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

Add Arg::conflicts_with_everything method #1583

Closed
CreepySkeleton opened this issue Oct 24, 2019 · 0 comments · Fixed by #1624
Closed

Add Arg::conflicts_with_everything method #1583

CreepySkeleton opened this issue Oct 24, 2019 · 0 comments · Fixed by #1624

Comments

@CreepySkeleton
Copy link
Contributor

Summary

Add explicit support for arguments that conflict with every other flag and must be always passed alone.

Detailed description and motivation

There are cases when we need to introduce a command line argument that should always be used standalone, i.e it conflicts with every other argument.

For now this can be implemented via conflicts_with_all but we have to explicitly enlist all the other flags then:

App::new("My daemon")
    .version("1.0")
        // this flag should be always passed alone, so it conflicts with any other flag
        .arg(Arg::with_name("status")
        .conflicts_with_all(&[
            // for now there's only one another flag so this is fairly simple
            // but once we have other arguments we have to pay some extra attention 
            // to not miss some accidentally          
            "SERIAL-PORT",
        ])
        .short("s")
        .long("status")
        .help("Daemon status"))
    .arg(Arg::with_name("SERIAL-PORT")
        .help("Sets the serial-port to use")
        .required(true))
    .get_matches();

Inspired by #1579

Dylan-DPC-zz pushed a commit that referenced this issue Jan 5, 2020
* feat: Add `Arg::conflicts_with_everything` method #1583

* fix: Typo in  src/build/arg/mod.rs

Co-Authored-By: Dylan DPC <dylan.dpc@gmail.com>

Co-authored-by: Dylan DPC <dylan.dpc@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant