Support python argcomplete
PATCH 1/1 Support python argcomplete
argcomplete is a alternative to shtab. While shtab provides an option to generate unique matching patterns for each program, argcomplete has a general completion hook that identifies compatible programs and dynamically pulls the completion out of the program itself.
This means that once argcomplete is enabled in the shell every compatible program automatically and effortlessly gets full shell completions that are perfectly up to date with the active version. When running out of a git check out this is a big improvement over shtab since completions Just Work with no need to specially manage the shtab files.
The boilerplate is setup so the argcomplete module is optional, if the user has it installed (and presumably enabled it for their shell) then it is activated.
--- b4.sh | 1 + src/b4/command.py | 7 +++++++ 2 files changed, 8 insertions(+)
b4.sh +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# PYTHON_ARGCOMPLETE_OK # # Run b4 from a git checkout. #
src/b4/command.py +7 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# PYTHON_ARGCOMPLETE_OK # -*- coding: utf-8 -*- # SPDX-License-Identifier: GPL-2.0-or-later # Copyright (C) 2020 by the Linux Foundation
@@ -1331,6 +1332,12 @@ def setup_parser() -> argparse.ArgumentParser: def cmd() -> None: parser = setup_parser() + try: + import argcomplete + argcomplete.autocomplete(parser) + except ImportError: + pass + cmdargs = parser.parse_args() logger.setLevel(logging.DEBUG)
base-commit: 362b87aa4d036884c36e4bfb9cdbdee626aba3bf
Signature · 1 line
2.43.0
Quoted 1 line · Jason Gunthorpe
Support python argcomplete
I've applied it, but note that this immediately fails ci.sh. I'll fix it up as a follow-up.
[1/1] Support python argcomplete
commit: f6b44c86c5c7b26f0979fe56ad76c40df11b9ccb
Best regards,
Signature · 1 line
Konstantin Ryabitsev <[email protected]>
Quoted 6 lines · Konstantin Ryabitsev
Quoted 1 line · Jason Gunthorpe
Support python argcomplete
I've applied it, but note that this immediately fails
ci.sh. I'll fix it up as a follow-up.
Thanks I had not discovered that! I will try it in future.
FWIW I am trying to use the b4 review to organize my unmanagable pile of patches to look at. It seems very promising, though I have a small list of pain points I may write up or try and fix :)
Jason