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

Feature request: ignore unspecified arguments #8

Closed
m4b opened this Issue Feb 27, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@m4b
Copy link

m4b commented Feb 27, 2017

This is a somewhat unusual request so if this isn't in your immediate plans, or ever, feel free to close. But I would be very happy to see it.

But the gist is I'd like to be able to have a sort of "non strictness mode" perhaps configured via builder, etc., which ignores any arguments which aren't spec'd by the argument struct.

Reason: I'm writing a tool that is a drop in replacement for another tool, and I want it to not die when it receives an argument it doesn't understand. This will allow me to incrementally implement certain features or choose to die on some flags (by implementing them), etc.

Is this something that's possible ?

Regardless awesome crate, already using it here, was painless to covert from basic toy arg iterator, I think you've got one of the nicest arg crates around at this point :) 👍

@TeXitoi

This comment has been minimized.

Copy link
Owner

TeXitoi commented Feb 27, 2017

I don't parse command line, I just forward all that to https://crates.io/crates/clap and I can't find this feature in clap.

Maybe a workaround is to get the generated clap object, add the arguments you want to ignore, and then parse. Something like that (not tested)

#[derive(StructOpt, PartialEq, Debug)]
struct Opt {
    #[structopt(short = "d", long = "debug")]
    debug: bool,
}
let app = Opt::clap().arg(Arg::with_name("v").short("v").long("verbose").help("Not implemented"));
let opt = Opt::from_clap(app.get_matches());

And thanks for the feedback!

@TeXitoi TeXitoi closed this Mar 15, 2017

@TeXitoi TeXitoi added the question label Feb 24, 2018

Eijebong pushed a commit to Eijebong/structopt that referenced this issue Jan 2, 2019

Merge pull request TeXitoi#8 from matthiaskrgr/fix_test_dep
"cargo test" requires png dependency. Fixes TeXitoi#7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment