clap icon indicating copy to clipboard operation
clap copied to clipboard

completions for subcommand aliases

Open dfgordon opened this issue 1 year ago • 2 comments

Please complete the following tasks

Clap Version

4.2.7

Describe your use case

A subcommand called catalog has aliases dir and ls. When clap_complete generates the zsh script it omits the aliases. As a result if a user tries ls they will not get the completions, and even worse, it tends to block the shell's natural path completions, making the tool less friendly instead of more.

Describe the solution you'd like

This appears easy to solve, you simply copy the block of the subcommand substituting the alias, such as

(mycommand)
...stuff
;;
(mycom)
...same stuff
;;

Alternatives, if applicable

No response

Additional Context

No response

dfgordon avatar Dec 03 '23 17:12 dfgordon

Without intervention zsh offers the aliases. With the intervention proposed above (tested) it still does so but also allows arguments to be completed. So far I didn't find any downside.

I have not tried with the other shells, except to note that bash is already handling it without any intervention.

Screenshot 2023-12-10 at 11 08 20 AM

dfgordon avatar Dec 10 '23 16:12 dfgordon

Minor note, tried all with clap and clap_complete 4.4.4, all results the same.

dfgordon avatar Dec 10 '23 16:12 dfgordon

isn't this a duplicate of #4265 ?

nasso avatar Mar 21 '24 14:03 nasso

Thanks for catching that!

epage avatar Mar 21 '24 14:03 epage