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',
|
'six',
|
||||||
'appdirs',
|
'appdirs',
|
||||||
'pyyaml',
|
'pyyaml',
|
||||||
|
'argparse',
|
||||||
|
'argcomplete',
|
||||||
],
|
],
|
||||||
setup_requires=[
|
setup_requires=[
|
||||||
'setuptools_scm',
|
'setuptools_scm',
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# PYTHON_ARGCOMPLETE_OK
|
||||||
""" CLI
|
""" CLI
|
||||||
|
|
||||||
This module acts as a command line interface for python-escpos. It mirrors
|
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
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
try:
|
||||||
|
import argcomplete
|
||||||
|
except ImportError:
|
||||||
|
# this CLI works nevertheless without argcomplete
|
||||||
|
pass # noqa
|
||||||
import sys
|
import sys
|
||||||
import six
|
import six
|
||||||
from . import config
|
from . import config
|
||||||
|
@ -499,6 +505,10 @@ def main():
|
||||||
help='Print the version of python-escpos')
|
help='Print the version of python-escpos')
|
||||||
parser_command_version.set_defaults(version=True)
|
parser_command_version.set_defaults(version=True)
|
||||||
|
|
||||||
|
# hook in argcomplete
|
||||||
|
if 'argcomplete' in globals():
|
||||||
|
argcomplete.autocomplete(parser)
|
||||||
|
|
||||||
# Get only arguments actually passed
|
# Get only arguments actually passed
|
||||||
args_dict = vars(parser.parse_args())
|
args_dict = vars(parser.parse_args())
|
||||||
if not args_dict:
|
if not args_dict:
|
||||||
|
|
Loading…
Reference in New Issue