kislyuk / argcomplete

Python and tab completion, better together.
https://kislyuk.github.io/argcomplete/
Apache License 2.0
1.39k stars 129 forks source link

Show only one of multiple names/flags #343

Open Maarten-vd-Sande opened 3 years ago

Maarten-vd-Sande commented 3 years ago

I am not sure if I missed it somewhere in the docs or issues, but I was wondering if it is possible to show only one (e.g. the first) of multiple names for an argument.

Let's say I do:

run.add_argument("-n", "--dryrun")

and then I use argcomplete on this:

$ my_tool [tab-tab]
-n --dryrun

I want only one of those two to show, not both. Is this somehow supported by argcomplete?

p.s. great tool :trophy:

evanunderscore commented 3 years ago

I believe you can supply any flags you don't want to see to exclude, e.g. argcomplete.autocomplete(exclude=['--dryrun']). Does this work for you?

Maarten-vd-Sande commented 3 years ago

Yes that works! :muscle:

However I have a bit more complex setup with subparsers, and it does not work for the subparsers unfortunately :(