diff --git a/setup.py b/setup.py index e4edbf3..7a3895b 100755 --- a/setup.py +++ b/setup.py @@ -110,6 +110,8 @@ setup( 'six', 'appdirs', 'pyyaml', + 'argparse', + 'argcomplete', ], setup_requires=[ 'setuptools_scm', diff --git a/src/escpos/cli.py b/src/escpos/cli.py index 5457df5..3e3311d 100644 --- a/src/escpos/cli.py +++ b/src/escpos/cli.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# PYTHON_ARGCOMPLETE_OK """ CLI This module acts as a command line interface for python-escpos. It mirrors @@ -14,6 +15,11 @@ from __future__ import print_function from __future__ import unicode_literals import argparse +try: + import argcomplete +except ImportError: + # this CLI works nevertheless without argcomplete + pass # noqa import sys import six from . import config @@ -499,6 +505,10 @@ def main(): help='Print the version of python-escpos') parser_command_version.set_defaults(version=True) + # hook in argcomplete + if 'argcomplete' in globals(): + argcomplete.autocomplete(parser) + # Get only arguments actually passed args_dict = vars(parser.parse_args()) if not args_dict: