add basic argcomplete support
This commit is contained in:
parent
457c62cc7f
commit
80b714fdae
2
setup.py
2
setup.py
|
@ -110,6 +110,8 @@ setup(
|
|||
'six',
|
||||
'appdirs',
|
||||
'pyyaml',
|
||||
'argparse',
|
||||
'argcomplete',
|
||||
],
|
||||
setup_requires=[
|
||||
'setuptools_scm',
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue