feat: check for activate-global-python-argcomplete on PATH
- Check if activate-global-python-argcomplete is available on system PATH - If available, assume global completion is already set up via shell - Otherwise, enable completion directly on this parser - Graceful fallback if argcomplete is not installed Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
+17
-10
@@ -7,12 +7,6 @@ It delegates commands to the appropriate sub-tools (e.g., librarian, mdoctor).
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
try:
|
||||
import argcomplete # pragma: no cover
|
||||
HAS_ARGCOMPLETE = True # pragma: no cover
|
||||
except ImportError:
|
||||
HAS_ARGCOMPLETE = False # pragma: no cover
|
||||
|
||||
from librarian.librarian import main as librarian_main
|
||||
from librarian.toc_generator import main as toc_generator_main
|
||||
from mdoctor.fmlint import main as fmlint_main
|
||||
@@ -27,11 +21,24 @@ def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Fiona-Assistant - Tools for managing the LLM wiki."
|
||||
)
|
||||
subparsers = parser.add_subparsers(dest="command", help="Available commands")
|
||||
|
||||
# Enable argcomplete if available
|
||||
if HAS_ARGCOMPLETE: # pragma: no cover
|
||||
argcomplete.autocomplete(parser) # pragma: no cover
|
||||
# Enable argcomplete for tab completion (if available)
|
||||
try:
|
||||
import shutil
|
||||
|
||||
import argcomplete
|
||||
|
||||
# Check if activate-global-python-argcomplete is available on PATH
|
||||
if shutil.which("activate-global-python-argcomplete") is not None: # pragma: no cover
|
||||
# argcomplete's global activation is already set up via the shell
|
||||
pass
|
||||
else:
|
||||
# Enable completion for this parser directly
|
||||
argcomplete.autocomplete(parser) # pragma: no cover
|
||||
except ImportError:
|
||||
# argcomplete not installed, completion won't work but CLI still functions
|
||||
pass # pragma: no cover
|
||||
subparsers = parser.add_subparsers(dest="command", help="Available commands")
|
||||
|
||||
# fiona-assistant librarian
|
||||
librarian_parser = subparsers.add_parser("librarian", help="Manage LLM wiki content")
|
||||
|
||||
Reference in New Issue
Block a user