summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2021-12-23 12:26:56 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2021-12-23 12:27:15 +0100
commite909231d76cd5a4ad1b6f28f577e59d00483a431 (patch)
treef875db5f86af876c249738365da0028419d4546e
parent926e844ce6c32b0773310fd21dbab6850d4ce010 (diff)
Add support for bash autocompletion via argcomplete, if installed.
-rw-r--r--CHANGELOG.rst1
-rw-r--r--lesana/command.py7
2 files changed, 8 insertions, 0 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index feec380..c01bd47 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -19,6 +19,7 @@ Unreleased
entries, while ``lesana search`` with no other options will list the
first 12 entries (possibly according to a default sorting setting).
* New collection example: ticket_tracker.
+* Add support for bash autocompletion via argcomplete, if installed.
Bugfixes
--------
diff --git a/lesana/command.py b/lesana/command.py
index 4c723af..6914ca3 100644
--- a/lesana/command.py
+++ b/lesana/command.py
@@ -4,6 +4,11 @@ import os
import subprocess
import sys
+try:
+ import argcomplete
+except ImportError as e:
+ argcomplete = False
+
from . import Collection, Entry, TemplatingError
logger = logging.getLogger(__name__)
@@ -40,6 +45,8 @@ class MainCommand:
for arg in sub.arguments:
s_parser.add_argument(*arg[0], **arg[1])
s_parser.set_defaults(func=sub._main)
+ if argcomplete:
+ argcomplete.autocomplete(self.parser)
self.args = self.parser.parse_args()
if self.args.verbose: