diff --git a/README.rst b/README.rst index ee8e189..2e79ca4 100644 --- a/README.rst +++ b/README.rst @@ -82,6 +82,7 @@ Extras ``ntfy`` has a few features that require extra dependencies. * ``ntfy done -p $PID`` requires installing as ``pip install ntfy[pid]`` * `emoji `_ support requires installing as ``pip install ntfy[emoji]`` + * `autocomplete `_ support requires installing as ``pip install ntfy[autocomplete]`` * `XMPP `_ support requires installing as ``pip install ntfy[xmpp]`` * `Telegram `_ support requires installing as ``pip install ntfy[telegram]`` * `Instapush `_ support requires installing as ``pip install ntfy[instapush]`` diff --git a/ntfy/cli.py b/ntfy/cli.py index 7dad0b2..1d5fbdd 100644 --- a/ntfy/cli.py +++ b/ntfy/cli.py @@ -1,3 +1,4 @@ +# PYTHON_ARGCOMPLETE_OK import argparse import logging import logging.config @@ -26,6 +27,11 @@ except ImportError: psutil = None +try: + import argcomplete +except ImportError: + argcomplete = None + try: from .terminal import is_focused except ImportError: @@ -294,6 +300,8 @@ def default_sender(args): def main(cli_args=None): + if argcomplete is not None: + argcomplete.autocomplete(parser) if cli_args is not None: args = parser.parse_args(cli_args) else: diff --git a/setup.py b/setup.py index 1008f5f..531891a 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,7 @@ 'instapush': ['instapush'], 'emoji': ['emoji'], 'pid':['psutil'], + 'autocomplete':['argcomplete'], 'slack':['slack_sdk'], 'rocketchat':['rocketchat-API'], 'matrix':['matrix_client'],