-
-
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
fish/complete: Generate helper functions to check for subcommands #5568
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tesuji
force-pushed
the
fish-nested-sub
branch
3 times, most recently
from
July 5, 2024 21:00
a4b755c
to
fc5fbe1
Compare
tesuji
changed the title
fish/complete: Generate helpers script to check for subcommands
fish/complete: Generate helper functions to check for subcommands
Jul 5, 2024
epage
reviewed
Jul 5, 2024
epage
reviewed
Jul 5, 2024
tesuji
force-pushed
the
fish-nested-sub
branch
3 times, most recently
from
July 6, 2024 00:57
f1182cb
to
1d94540
Compare
Nested subcommand more than 3 levels is not practical in public. Take rustup for example, `rustup toolchain install <version>`, there is only 3 levels of nested subcommands. But there is also the case of `rustup help toolchain install`, or `rustup toolchain help install`.
epage
reviewed
Jul 6, 2024
epage
reviewed
Jul 8, 2024
epage
reviewed
Jul 8, 2024
epage
reviewed
Jul 8, 2024
Alright, thanks for bearing with my unclear explanation. I tried to do better with new pushed commits. |
Thanks for working on this and your patience through the rounds of feedback! |
I'm very thankful for your guide/help through the code, raising helpful questions that I explained very poorly. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As guided by fish's maintainer, to handle nested subcommands, we try to generate 3 new functions for completion scripts:
__fish_{name}_global_optspecs
will gather global option specifications,__fish_{name}_needs_command
, withrustup \t
, used to check forrustup
__fish_{name}_using_subcommand show
, withrustup show \t
, check if current cmd isshow
This pattern is popular within fish-shell repository, for some commands:
This is complicated, as stated by fish's maintainers. Let's hope the new fish proposal will improve things.
This PR contains a HACK: Assuming subcommands are only nested less than 3 levels as more than that is unwieldy and takes more effort to support. For example,
rustup toolchain help install
is the longest valid command line ofrustup
that uses nested subcommands, and it cannot receive any flags to it.