clap-rs / clap

A full featured, fast Command Line Argument Parser for Rust
docs.rs/clap
Apache License 2.0
13.64k stars 1.02k forks source link

fish: `foo help \t` cannot suggest any completions for subcommands #5555

Open tesuji opened 6 days ago

tesuji commented 6 days ago

Look at the generated completion

https://github.com/clap-rs/clap/blob/5cc44bb91ee3a13aad65a41fdf687fe7f30b8bdc/clap_complete/tests/snapshots/basic.fish#L9

The condition after -n is simplify as true && not true which equates to false, so the completion is never taken into account.

First noticed by https://github.com/clap-rs/clap/pull/4115#issuecomment-1631714950.

epage commented 6 days ago

If I'm understanding this correctly, the way fish has us process subcommands is that we check if a subcommand has been seen and then give options for what can happen within that subcommand.

It sounds like there isn't a way to process nested subcommands then because we can only check for set membership and not hierarchy. This would imply a lot more is broken then the case mentioned and likely can only be fixed with #3166.

tesuji commented 5 days ago

Maybe I am wrong. Testing with rustup help \t seems to be working as expected.

> rustup help \t
active-toolchain                              (Show the active toolchain)  profile  (The default components installed with a toolchain)
add                                 (Add a component to a Rust toolchain)  remove            (Remove a component from a Rust toolchain)
auto-self-update                       (The rustup auto self update mode)  set             (Set the override toolchain for a directory)
default-host  (The triple used to identify toolchains when not specified)  uninstall                                 (Uninstall rustup)
home                          (Display the computed value of RUSTUP_HOME)  unset        (Remove the override toolchain for a directory)
install                             (Install or update a given toolchain)  update              (Download and install updates to rustup)
link             (Create a custom toolchain by symlinking to a directory)  upgrade-data              (Upgrade the internal data format)
list                                 (List directory toolchain overrides)

I'm not an expert in fish completion. So maybe cc @mqudsi for help.

I'll close the issue if there is no respond for a week. Sorry for waiting your time.