-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
AppSettings::AllowExternalSubcommands [sometimes] triggers suggestions #1169
Comments
Currently the fix is to not compile the [dependencies.clap]
version = "2"
default-features = false
features = ["color", "wrap_help"] # assuming one would still want the other defaults This is a hard one to solve generally for the masses because clap has to match incoming arguments to something and if they happen to be close enough to trigger a "possible subcommand" there's no way for clap to know if this is what this particular use case wanted or not. A future fix would be to add a I can look at adding it in v3 if no one has knocked it out by then. |
Kevin,
Thank you so much for the detailed explanation.
I suspect this might be a good solution for my use case where I'm trying
(in the absence of a matching subcommand) to see if I can execute
myprog-given-subcommand. What I was trying to accomplish was along the
lines of "try to match these subcommands without suggestions first, if it
fails, try finding the external binary; if there is none, enable
suggestions and run matching again". But obviously this doesn't work well
when suggestions are enabled or disabled compile time.
I'll try to see if I can prepare a patch for this.
On Feb 10, 2018 10:54 AM, "Kevin K." <notifications@github.com> wrote:
Currently the fix is to not compile the suggestions feature.
[dependencies.clap]version = "2"default-features = falsefeatures =
["color", "wrap_help"] # assuming one would still want the other
defaults
This is a hard one to solve generally for the masses because clap has to
match incoming arguments to *something* and if they happen to be close
enough to trigger a "possible subcommand" there's no way for clap to know
if this is what this particular use case wanted or not.
A future fix would be to add a AppSettings::DontUseSuggestions which would
only apply to the current (sub)command. Possibly also narrowed down at a
later date with the ability to only not suggest on flags/options or
subcommands. I'll mark this as a todo, or good first issue for someone.
I can look at adding it in v3 if no one has knocked it out by then.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1169 (comment)>,
or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAABxMeWT1w2HZukDQ_xd1TU2mefKEl0ks5tTRLqgaJpZM4R9zl2>
.
|
Awesome! If you'd like to try this issue, I'd suggest adding a new setting (by following the examples of all other settings) in I'd also add some tests to |
It looks like 2.31.2 solves this issue (#1215), at least to some degree. I was just able to use it the way I intended to: |
Rust Version
rustc 1.23.0 (766bd11c8 2018-01-01)
Affected Version of clap
2.29.4
Expected Behavior Summary
The program executions to print:
Actual Behavior Summary
Steps to Reproduce the issue
src/main.rs:
Run with
Debug output
The text was updated successfully, but these errors were encountered: