-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Parser panics using global args and calling get_matches_from_safe_borrow()
repeatedly
#1076
Comments
Would you mind testing this against the the current master branch? I just merged #1075 which deals with global args quite heavily and would like to know if that solves the issue. |
I updated the demonstration repository to use the current master branch. Unfortunately the PR doesn't fix this issue. I also updated the debug log in the gist linked above. |
👍 |
I have this fixed in a local branch, I'll upload and put in the PR once I get home today. |
Thanks for the fast fix and this convenient and powerful crate! |
Rust Version
rustc 1.21.0 (3b72af97e 2017-10-09)
Affected Version of clap
v2.26.2
Expected Behavior Summary
A global argument (
Arg::with_name("vm name").global(true)
) should be usable when callingget_matches_from_safe_borrow()
multiple times on the sameApp
.Actual Behavior Summary
The second time clap parses some input it panics and reports "Non-unique argument name: vm name is already in use". (See debug output)
Due to
AppSetting::NoBinaryName
andget_matches_from_safe_borrow()
available I concluded it would be safe to reuse anApp
instance parsing many input lines. Except for the global arguments other features work well in my REPL-style cli application.Alternatively I could clone the
App
and reset it before parsing another line of input. Do you consider reusing theApp
instance an API misuse and suggest to useclone()
and reset, or is this an actual bug that should be fixed?Steps to Reproduce the issue
cargo run -- help
help
into the REPLSample Code or Link to Sample Code
https://github.com/tomprogrammer/clap-global-issue
Debug output
https://gist.github.com/tomprogrammer/4063db64a246b3d2d4bf472cec94fbda
The text was updated successfully, but these errors were encountered: