iterative / shtab

↔️ Automagic shell tab completion for Python CLI applications
https://docs.iterative.ai/shtab
Other
363 stars 35 forks source link

[feature] support choice with description? #88

Open Freed-Wu opened 2 years ago

Freed-Wu commented 2 years ago

zsh/fish support choices with description, like:

❯ pip download --<TAB>
implementation
cp   cpython
ip   ironpython
jy   jython
pp   pypy
py   implementation-agnostic

A new feature

    parser.add_argument("--implementation", choices=["py", "cp", "pp", "ip", "jy"]).complete = {"cpython", "ironpython", "jython", "pypy", "implementation-agnostic"}
    # len(complete) must = len(choices), or complete must be a dict which keys is choices

Result:

  "--implementation: :((pp\:pypy jy\:jython cp\:cpython ip\:ironpython py\:implementation-agnostic))"