-
-
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
Add support for completing --flag value<TAB>
, -fbar<TAB>
, -f=bar<TAB>
and -f bar<TAB>
#5533
Conversation
097482c
to
a9f4b5a
Compare
The current code hasn't been tested a lot. I've just done some quick tests using the dynamic program from the tests. |
.vscode/launch.json
Outdated
@@ -0,0 +1,5 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this. I don't want to get into the business of having the config files for every users editor in my repos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(in git, you can configure a user-wide ignore and place these here for yourself)
/// Complete the given command | ||
/// NOTE: borrow the idea from Parser.rs::ParseState to record the state during completion.s | ||
#[derive(Debug, PartialEq, Eq, Clone)] | ||
enum CompletionState { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's call this ParseState
to be more specific (and match clap's parser)
/// Complete the given command | ||
/// NOTE: borrow the idea from Parser.rs::ParseState to record the state during completion.s | ||
#[derive(Debug, PartialEq, Eq, Clone)] | ||
enum CompletionState { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: we generally put implementation details for logic after the logic (so move this after complete
)
I need to split this PR into smaller PRs for easier discussion and review. How should I handle the situation where one resulting PR might be based on another PR? |
54581a0
to
4f03598
Compare
Either hold off on the follow up PRs or put them up, note the dependency, and rebase once the other PR is merged. |
Related issues:
In this PR, I modified some logic in the complete function:
CompletionState
to record the current parsing state during completion parsing. When completion is triggered withtarget_cursor
equal tocursor
, the completion function will be chosen based on theCompletionState
.complete
function for arg over subcommand, optional long flag, escape, negative number, optional short flag, stdio, and empty.complete_arg
forarg
, with the same priority as above.There are some TODOs in this PR that I will implement later, including:
args_conflicts_with_subcommands
subcommand_precedence_over_arg
multicall