Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shell completion #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://en.wikipedia.org/wiki/Emoji>`_ support requires installing as ``pip install ntfy[emoji]``
* `autocomplete <https://argcomplete.readthedocs.io>`_ support requires installing as ``pip install ntfy[autocomplete]``
* `XMPP <https://xmpp.org/>`_ support requires installing as ``pip install ntfy[xmpp]``
* `Telegram <https://telegram.org/>`_ support requires installing as ``pip install ntfy[telegram]``
* `Instapush <https://instapush.im/>`_ support requires installing as ``pip install ntfy[instapush]``
Expand Down
8 changes: 8 additions & 0 deletions ntfy/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# PYTHON_ARGCOMPLETE_OK
import argparse
import logging
import logging.config
Expand Down Expand Up @@ -26,6 +27,11 @@
except ImportError:
psutil = None

try:
import argcomplete
mohd-akram marked this conversation as resolved.
Show resolved Hide resolved
except ImportError:
argcomplete = None

try:
from .terminal import is_focused
except ImportError:
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'instapush': ['instapush'],
'emoji': ['emoji'],
'pid':['psutil'],
'autocomplete':['argcomplete'],
'slack':['slack_sdk'],
'rocketchat':['rocketchat-API'],
'matrix':['matrix_client'],
Expand Down