daedalus 0.3.0: argparse CLI + argcomplete shell completion, script-arg delegation
- cli.py rewritten on argparse (build_parser, REMAINDER pass-through: everything after the script name still belongs to the script); help/errors are argparse-rendered, exit code 2 kept for all daedalus errors - completions.py (new): category-aware candidates for argcomplete - script names + unused labels narrowed by typed labels (daedalus test h<TAB> -> hello); --path completes scripts; after a completed script name daedalus offers nothing of its own and delegates .py scripts to their own parser via the run_python_script child with a rewritten COMP_LINE (daedalus hello -<TAB> -> hello's -h --help); SPEC 6.9 documents the autocomplete(parser) opt-in - SPEC: item 1.5 reuse-first third-party policy, 3.8/3.10/3.11 argparse texts, 3.13 completion catalog, 6.9 script opt-in, 9.6 argcomplete dependency - argcomplete>=3.3 as runtime dep (guarded import: CLI runs without it); register-python-argcomplete line for ~/.bashrc; PYTHON_ARGCOMPLETE_OK marker in bin/daedalus; README/INSTALL/CHANGELOG updated; hello opts in - tests: argparse CLI suites, completer units, end-to-end argcomplete probes through the bash fd-8 protocol and the delegation exec chain (autotest green, coverage 97%) Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -12,6 +12,11 @@ import pathlib
|
||||
import sys
|
||||
import tomllib
|
||||
|
||||
try: # SPEC item 6.9: complete hello's own arguments
|
||||
from argcomplete import autocomplete
|
||||
except ImportError: # pragma: no cover - completion off without argcomplete
|
||||
autocomplete = None
|
||||
|
||||
UNKNOWN = "unknown"
|
||||
|
||||
|
||||
@@ -35,6 +40,8 @@ def main(argv: list[str] | None = None) -> int:
|
||||
"""Print ``hello from daedalus <version>``; return the exit code."""
|
||||
parser = argparse.ArgumentParser(prog="hello",
|
||||
description=__doc__.splitlines()[0])
|
||||
if autocomplete is not None: # SPEC item 6.9
|
||||
autocomplete(parser)
|
||||
parser.parse_args(argv)
|
||||
print(f"hello from daedalus {app_version()}")
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user