changeset 68b41353f44e in modules/country:default
details: https://hg.tryton.org/modules/country?cmd=changeset&node=68b41353f44e
description:
        Add command line completion with argcomplete

        issue11592
        review419481003
diffstat:

 scripts/import_countries.py    |  8 ++++++++
 scripts/import_postal_codes.py |  8 ++++++++
 setup.py                       |  1 +
 3 files changed, 17 insertions(+), 0 deletions(-)

diffs (71 lines):

diff -r 39c239a232da -r 68b41353f44e scripts/import_countries.py
--- a/scripts/import_countries.py       Mon May 02 16:42:45 2022 +0200
+++ b/scripts/import_countries.py       Fri Aug 26 18:12:02 2022 +0200
@@ -1,4 +1,5 @@
 #!/usr/bin/env python3
+# PYTHON_ARGCOMPLETE_OK
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
 import gettext
@@ -9,6 +10,11 @@
 import pycountry
 
 try:
+    import argcomplete
+except ImportError:
+    argcomplete = None
+
+try:
     from progressbar import ETA, Bar, ProgressBar, SimpleProgress
 except ImportError:
     ProgressBar = None
@@ -184,6 +190,8 @@
     parser.add_argument('-d', '--database', dest='database', required=True)
     parser.add_argument('-c', '--config', dest='config_file',
         help='the trytond config file')
+    if argcomplete:
+        argcomplete.autocomplete(parser)
 
     args = parser.parse_args()
     main(args.database, args.config_file)
diff -r 39c239a232da -r 68b41353f44e scripts/import_postal_codes.py
--- a/scripts/import_postal_codes.py    Mon May 02 16:42:45 2022 +0200
+++ b/scripts/import_postal_codes.py    Fri Aug 26 18:12:02 2022 +0200
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+# PYTHON_ARGCOMPLETE_OK
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
 from __future__ import print_function
@@ -18,6 +19,11 @@
 from io import BytesIO, TextIOWrapper
 
 try:
+    import argcomplete
+except ImportError:
+    argcomplete = None
+
+try:
     from progressbar import ETA, Bar, ProgressBar, SimpleProgress
 except ImportError:
     ProgressBar = None
@@ -122,6 +128,8 @@
     parser.add_argument('-c', '--config', dest='config_file',
         help='the trytond config file')
     parser.add_argument('codes', nargs='+')
+    if argcomplete:
+        argcomplete.autocomplete(parser)
 
     args = parser.parse_args()
     main(args.database, args.codes, args.config_file)
diff -r 39c239a232da -r 68b41353f44e setup.py
--- a/setup.py  Mon May 02 16:42:45 2022 +0200
+++ b/setup.py  Fri Aug 26 18:12:02 2022 +0200
@@ -145,6 +145,7 @@
         'data': ['pycountry', get_require_version('proteus')],
         'test': tests_require,
         'GeoNames': [get_require_version('proteus')],
+        'completion': ['argcomplete'],
         },
     dependency_links=dependency_links,
     zip_safe=False,

Reply via email to