iterative / shtab

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

add convenience functions #18

Closed casperdcl closed 4 years ago

casperdcl commented 4 years ago

from https://www.reddit.com/r/Python/comments/hyyl30/weve_release_an_open_source_lib_to_generate_tab/fzhj3uv/ and specifically https://gist.github.com/mpkocher/b338f416a7d0b1778d28a514c124dc16#gistcomment-3396016, would be nice to have convenience functions:

parser = argparse.ArgumentParser(...)
...
shtab.add_argument_to(parser)  # adds `[--print-completion-shell={bash,zsh}]` option
shtab.add_parser_to(parser)  # adds `completion [{--bash,--zsh}]` subcommand

the convenience functions would also handle the print logic too, so no further modification would be required.

CC @mpkocher