Closed tesuji closed 2 months ago
Alright, thanks for bearing with my unclear explanation. I tried to do better with new pushed commits. Let me know if you have any questions.
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.
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.