annotations: add command line autocompletion
authorAndrea Righi <andrea.righi@canonical.com>
Thu, 15 Jun 2023 15:36:35 +0000 (17:36 +0200)
committerAndrea Righi <andrea.righi@canonical.com>
Fri, 16 Jun 2023 10:10:09 +0000 (12:10 +0200)
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
debian/control
debian/rules
kconfig/run.py
requirements.txt [new file with mode: 0644]
setup.py

index f6de84987279ea908fd780705c8b49deb6506b8e..d5c16e27e929384853ff7e6cca5e002c2d3fb61c 100644 (file)
@@ -3,7 +3,7 @@ Section: misc
 Priority: optional
 Maintainer: Andrea Righi <andrea.righi@canonical.com>
 Standards-Version: 4.5.1
-Build-Depends: debhelper (>= 11), dh-python, python3, python3-setuptools
+Build-Depends: debhelper (>= 11), dh-python, python3, python3-setuptools, python3-argcomplete
 Homepage: https://git.launchpad.net/~arighi/+git/annotations-tools
 Vcs-Git:  https://git.launchpad.net/~arighi/+git/annotations-tools
 
index 641186e52d53d2f9909aad1be3c94f383b296efd..d3273c92701a7677deb3ae9e7d4ebd484ae7bd14 100755 (executable)
@@ -1,4 +1,12 @@
 #!/usr/bin/make -f
 
+annotations-prompt:
+       register-python-argcomplete annotations > $@
+
 %:
        dh $@ --with python3 --buildsystem=pybuild
+
+override_dh_install: annotations-prompt
+       dh_install
+       mkdir -p $(CURDIR)/debian/annotations/etc/bash_completion.d
+       install -m 0644 annotations-prompt $(CURDIR)/debian/annotations/etc/bash_completion.d/annotations-prompt
index 86d858611780dfb48ad639d8161db72c09bd3f90..cf133b3e97e5de89b018ad016b90b7961ccac482 100644 (file)
@@ -9,6 +9,7 @@ import os
 import argparse
 import json
 from signal import signal, SIGPIPE, SIG_DFL
+from argcomplete import autocomplete
 
 from kconfig.annotations import Annotation, KConfig
 
@@ -244,6 +245,7 @@ def main():
     signal(SIGPIPE, SIG_DFL)
 
     # Main annotations program
+    autocomplete(_ARGPARSER)
     args = _ARGPARSER.parse_args()
     autodetect_annotations(args)
 
diff --git a/requirements.txt b/requirements.txt
new file mode 100644 (file)
index 0000000..e60624f
--- /dev/null
@@ -0,0 +1 @@
+argcomplete
index 77fee4ae5c8d4c90165e0f0248a8833d38772014..622a856df63d307bbbdcbba8fb79797b14449c80 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -17,6 +17,7 @@ setup(
                                        'README.rst'), 'r').read(),
     long_description_content_type="text/x-rts",
     packages=['kconfig'],
+    install_requires=['argcomplete'],
     entry_points = {
         'console_scripts': [
             'annotations = kconfig.run:main',