From 1e403b51cbd3c49df58f618109a553fdb9d04f5c Mon Sep 17 00:00:00 2001 From: Ondrej Nosek Date: Dec 05 2018 13:47:43 +0000 Subject: Initialize bash autocompletion Signed-off-by: Ondrej Nosek --- diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index 32a9cbe..bdf1fc8 100644 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -13,26 +13,35 @@ # LGPLv2.1. See comments before those functions. from __future__ import print_function + import argparse import getpass import logging import os import random -import requests -from requests.auth import HTTPBasicAuth +import re import string import sys import time -import re -# For `_ArgumentParser' -from gettext import gettext as _ +from gettext import gettext as _ # For `_ArgumentParser' + +import requests +import six +from requests.auth import HTTPBasicAuth +from six.moves import configparser import koji_cli.lib import pyrpkg.utils as utils -import six +from pyrpkg import PY26 +from pyrpkg import log as rpkgLogger +from pyrpkg import rpkgError -from pyrpkg import PY26, rpkgError, log as rpkgLogger -from six.moves import configparser +# argcomplete might not be available for all products which +# use rpkg as a library (for example centpkg) +try: + import argcomplete +except ImportError: + argcomplete = None def warning_deprecated_dist(value): @@ -2375,6 +2384,9 @@ see API KEY section of copr-cli(1) man page. sys.exit(0) # no return possible + # initialize bash autocompletion + if argcomplete is not None: + argcomplete.autocomplete(self.parser) # Parse the args self.args = self.parser.parse_args()