diff --git a/CHANGELOG.md b/CHANGELOG.md index 01ec5e3..340453a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,25 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and - Nothing yet. +## [0.4.0] - 2026-11-18 + +### Added in 0.4.0 + +- `bash/daedalus_common.sh`: the shared interface for bash scripts (SPEC + item 6.10) — a script sources its sibling helper, defines `help()` + (usage) and `main()`, and ends with `daedalus_bash_dispatch "$@"`, + which routes `help` / `-h` / `--help` to `help()` and everything else + to `main()` unchanged. +- Bash script completion (SPEC item 3.13.5.2): `daedalus ` + completes `--help`, `-h`, and `help` for scripts implementing the + interface; no script runs on TAB. Scripts without the interface get + the shell default. +- `bash/hello_bash.sh`: sample bash script (category `test`) through the + shared interface, the bash twin of `hello`, with tests. +- `bash/tests/`: the interface tests — helper behavior through a + sample script and enforcement of the interface for every registered + `.sh` script. + ## [0.3.0] - 2026-11-18 ### Added in 0.3.0 diff --git a/INSTALL.md b/INSTALL.md index 5c08e48..57a9886 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -157,6 +157,11 @@ Notes: that calls `argcomplete.autocomplete(parser)` (SPEC item 6.9) completes its own arguments — `daedalus hello -` offers hello's `-h`, `--help`. Otherwise the shell offers file names there. +- Bash scripts share `bash/daedalus_common.sh` (SPEC item 6.10): the + script sources it, defines `help()` and `main()`, and ends with + `daedalus_bash_dispatch "$@"`. After the script name, TAB offers + `--help`, `-h`, and `help`; running one of them prints the script's + `help()`. - A checkout run through `bin/daedalus` completes when the `python3` it runs can `import argcomplete` and the marker comment stays in the launcher (SPEC item 3.13.7). diff --git a/README.md b/README.md index 20a8c84..a0e1a51 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,14 @@ daedalus --list # list everything | Script | Type | Categories | What it does | | --- | --- | --- | --- | | `hello` | Python | test | Prints a hello line and the daedalus version | +| `hello_bash` | Bash | test | Sample bash script through the shared help() interface | Run the sample script: ```bash -daedalus hello # hello from daedalus 0.3.0 +daedalus hello # hello from daedalus 0.4.0 +daedalus hello_bash me # hello, me (from daedalus bash) +daedalus hello_bash -h # usage from hello_bash's help() daedalus test hello # same, through the category prefix daedalus test # list the scripts in the 'test' category ``` @@ -41,7 +44,8 @@ See [INSTALL](./INSTALL.md#tab-completion). 1. Clone or copy this template and name the Git remote for your team. 2. Add a script under `python/src/`, `bash/`, `powershell/`, or `batch/` - (see [SPEC layout](./SPEC.md#2-layout)). + (see [SPEC layout](./SPEC.md#2-layout)); bash scripts implement the + shared `help()` interface (SPEC item 6.10). 3. Register it in `daedalus/registry.py`, add a row to the table above, write tests, bump `version` in `pyproject.toml`, and run `python autotest.py`. diff --git a/SPEC.md b/SPEC.md index 1faf5b7..85ace25 100644 --- a/SPEC.md +++ b/SPEC.md @@ -79,7 +79,8 @@ daedalus/ ├── python/ │ ├── src// # Python scripts, one folder per script │ └── tests/ # pytest tests for python/src, .ps1, .bat -├── bash/ # *.sh scripts +├── bash/ # *.sh scripts (SPEC item 6.10 interface) +│ ├── daedalus_common.sh # shared helper: daedalus_bash_dispatch, help() routing │ └── tests/ # pytest tests that run them ├── powershell/ # *.ps1 scripts ├── batch/ # *.bat scripts (CRLF) @@ -298,8 +299,12 @@ help. through, and the completion channel (fd 8) inherited. The script completes its arguments (SPEC item 6.9); quoting in the words is not preserved in the rewrite. - - **3.13.5.2** bash, PowerShell, and batch scripts get no - candidates: the shell default completion (file names) applies. + - **3.13.5.2** A `.sh` script that implements the interface (SPEC item + 6.10) completes the help words `--help`, `-h`, and `help`, filtered + by the word being typed; daedalus writes them itself on the + completion channel — no script runs on TAB. A `.sh` script without + the interface, and `.ps1` / `.bat` scripts, get no candidates: the + shell default (file names) applies. - **3.13.6** The completion hook re-runs the `daedalus` command on `PATH`: the program that runs on TAB must import argcomplete (installed dependency, or the dev venv, or the system package) and @@ -466,6 +471,30 @@ SCRIPTS: dict[str, Script] = { shell default, and a TAB can run the script itself (argcomplete semantics — scripts that must not run on TAB do not opt in or keep their parser behind a subcommand). +- **6.10** Bash script interface. Every `*.sh` script registered in + `SCRIPTS` implements the shared interface through + `bash/daedalus_common.sh`: + - **6.10.1** Near the top, the script sources the sibling helper + exactly once: + + ```bash + # shellcheck source=/dev/null + . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/daedalus_common.sh" + ``` + + - **6.10.2** The script defines `help()`, which prints its usage and + option list: the words `daedalus ` completes (SPEC item + 3.13.5.2) route to it. + - **6.10.3** The script defines `main()` with the body; `main "$@"` + receives the script arguments unchanged. + - **6.10.4** The last statement is `daedalus_bash_dispatch "$@"`: the + helper routes `help`, `-h`, and `--help` to `help()` (exit status of + `help`), every other invocation to `main() "$@"` (exit status of + `main`). The help words are reserved for the dispatch in every + bash script. + - **6.10.5** `bash/tests/` enforces the interface for every + registered `.sh` script (source line, `help()`, `main()`, the + dispatch call) and tests the helper behavior directly. ## 7. Quality gates diff --git a/bash/daedalus_common.sh b/bash/daedalus_common.sh new file mode 100644 index 0000000..5b0f415 --- /dev/null +++ b/bash/daedalus_common.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# Shared interface for daedalus bash scripts (SPEC.md item 6.10). +# +# A registered bash script sources this sibling file once and ends with: +# daedalus_bash_dispatch "$@" +# The script defines help() (its usage text) and main() (its body). +# daedalus completes the help words for the script (SPEC item 3.13.5.2); +# this helper runs them: help, -h, and --help print help(), everything +# else goes to main() with the arguments unchanged. + +help() { + echo "bash script error: help() is not defined (SPEC item 6.10.2)" >&2 + return 2 +} + +main() { + echo "bash script error: main() is not defined (SPEC item 6.10.3)" >&2 + return 2 +} + +daedalus_is_help_request() { + case "${1-}" in + help|-h|--help) return 0 ;; + *) return 1 ;; + esac +} + +daedalus_bash_dispatch() { + if daedalus_is_help_request "${1:-}"; then + help + local status=$? + exit "$status" + fi + main "$@" +} diff --git a/bash/hello_bash.sh b/bash/hello_bash.sh new file mode 100755 index 0000000..60a8146 --- /dev/null +++ b/bash/hello_bash.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# hello_bash: sample bash script for the shared interface (SPEC item 6.10). +# +# Run via daedalus: daedalus hello_bash [name...] +# It exists to exercise help() routing, main() dispatch, and the +# completion of the help words (SPEC item 3.13.5.2) end to end. +# shellcheck source=/dev/null +. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/daedalus_common.sh" + +help() { + cat <<'EOF' +usage: hello_bash [name...] + +Prints a hello line, once per name, default "world". +EOF +} + +main() { + local names=("$@") + ((${#names[@]})) || names=("world") + local name + for name in "${names[@]}"; do + echo "hello, ${name} (from daedalus bash)" + done +} + +daedalus_bash_dispatch "$@" diff --git a/bash/tests/test_bash_interface.py b/bash/tests/test_bash_interface.py new file mode 100644 index 0000000..96099fe --- /dev/null +++ b/bash/tests/test_bash_interface.py @@ -0,0 +1,82 @@ +"""Tests for the daedalus bash script interface (SPEC item 6.10). + +`bash/daedalus_common.sh` routes the help words to the script's help() +and everything else to its main(); every registered .sh script must +implement the interface. +""" +import re +import subprocess + +import pytest + +from daedalus import REPO_ROOT +from daedalus import registry + +COMMON = REPO_ROOT / "bash" / "daedalus_common.sh" + +SCRIPT_TEMPLATE = """#!/usr/bin/env bash +. "{common}" +help() {{ + echo "usage: sample [args...] (help from help)" +}} +main() {{ + echo "main $*" + echo "count $#" + return 3 +}} +daedalus_bash_dispatch "$@" +""" + + +@pytest.fixture +def sample(tmp_path): + """A minimal script that implements the interface (SPEC items 6.10.1-6.10.4).""" + path = tmp_path / "sample.sh" + path.write_text(SCRIPT_TEMPLATE.format(common=COMMON)) + path.chmod(0o755) + return path + + +def run(script, *args): + """Run a script with bash and capture everything.""" + return subprocess.run(["bash", str(script), *args], capture_output=True, + text=True, check=False) + + +@pytest.mark.parametrize("word", ["help", "-h", "--help"]) +def test_help_words_route_to_help(sample, word): + """help, -h, and --help print help() and exit with its status (SPEC item 6.10.4).""" + result = run(sample, word) + assert result.returncode == 0 + assert result.stdout == "usage: sample [args...] (help from help)\n" + + +@pytest.mark.parametrize("args, count", [(("build", "--x", "y z"), 3), ((), 0)]) +def test_main_receives_the_arguments(sample, args, count): + """Everything except the help words goes to main() unchanged (SPEC item 6.10.4).""" + result = run(sample, *args) + assert result.returncode == 3 + assert result.stdout.splitlines() == [f"main {' '.join(args)}", f"count {count}"] + + +def test_common_script_parses(): + """bash -n accepts the shared helper itself.""" + assert subprocess.run(["bash", "-n", str(COMMON)], check=False).returncode == 0 + + +def test_every_registered_bash_script_implements_the_interface(): + """Every .sh entry in SCRIPTS: source line, help(), main(), dispatch.""" + for name, script in sorted(registry.SCRIPTS.items()): + path = script.absolute_path + if path.suffix != ".sh": + continue + assert path.is_file(), f"{name}: {path} does not exist" + text = path.read_text(encoding="utf-8") + assert "daedalus_common.sh" in text, \ + f"{name} must source the shared helper (SPEC item 6.10.1)" + assert re.search(r"^help\s*\(\s*\)", text, re.MULTILINE), \ + f"{name} must define help() (SPEC item 6.10.2)" + assert re.search(r"^main\s*\(\s*\)", text, re.MULTILINE), \ + f"{name} must define main() (SPEC item 6.10.3)" + assert 'daedalus_bash_dispatch "$@"' in text, \ + f"{name} must end with the dispatch call (SPEC item 6.10.4)" diff --git a/bash/tests/test_hello_bash.py b/bash/tests/test_hello_bash.py new file mode 100644 index 0000000..87eaded --- /dev/null +++ b/bash/tests/test_hello_bash.py @@ -0,0 +1,102 @@ +"""Tests for hello_bash: the shared bash interface end to end (SPEC item 6.10). + +Direct runs, daedalus runs, help routing, and the completion of the help +words after the script name (SPEC item 3.13.5.2). +""" +import os +import shlex +import subprocess +import sys + +import pytest + +from daedalus import REPO_ROOT +from daedalus import registry + +SCRIPT = registry.SCRIPTS["hello_bash"].absolute_path + + +def run_script(*args): + """Run the script directly with bash.""" + return subprocess.run(["bash", str(SCRIPT), *args], capture_output=True, + text=True, check=False) + + +def run_daedalus(*args): + """Run python -m daedalus from the checkout, like the installed CLI.""" + env = {**os.environ, "PYTHONPATH": str(REPO_ROOT)} + return subprocess.run([sys.executable, "-m", "daedalus", *args], + capture_output=True, text=True, check=False, + cwd=REPO_ROOT.parent, env=env) + + +def test_main_defaults_to_world(): + """No arguments: one hello line for the default name.""" + result = run_script() + assert result.returncode == 0 + assert result.stdout == "hello, world (from daedalus bash)\n" + + +def test_main_prints_one_line_per_name(): + """Every name gets its hello line, arguments unchanged.""" + result = run_script("me", "you too") + assert result.returncode == 0 + assert result.stdout == ("hello, me (from daedalus bash)\n" + "hello, you too (from daedalus bash)\n") + + +@pytest.mark.parametrize("word", ["help", "-h", "--help"]) +def test_help_words_print_the_usage(word): + """The help words route to hello_bash's help() (SPEC item 6.10.4).""" + result = run_script(word) + assert result.returncode == 0 + assert result.stdout.startswith("usage: hello_bash [name...]") + assert "Prints a hello line" in result.stdout + + +def test_daedalus_runs_it(): + """daedalus hello_bash runs through the bash runner (SPEC item 5.3).""" + result = run_daedalus("hello_bash", "pi") + assert result.returncode == 0, result.stderr + assert result.stdout == "hello, pi (from daedalus bash)\n" + + +def test_daedalus_category_prefix_runs_it(): + """daedalus test hello_bash runs it through the category prefix.""" + result = run_daedalus("test", "hello_bash") + assert result.returncode == 0, result.stderr + assert result.stdout == "hello, world (from daedalus bash)\n" + + +def test_daedalus_help_word_passes_through(): + """daedalus hello_bash --help shows the script's help, not daedalus's (SPEC item 3.1).""" + result = run_daedalus("hello_bash", "--help") + assert result.returncode == 0, result.stderr + assert result.stdout.startswith("usage: hello_bash [name...]") + + +def _probe(comp_line): + """Replay the argcomplete hook and return the candidates (fd 8).""" + env = {**os.environ, "_ARGCOMPLETE": "1", "COMP_LINE": comp_line, + "COMP_POINT": str(len(comp_line)), "_ARGCOMPLETE_IFS": "\n", + "_ARGCOMPLETE_SHELL": "bash", "PYTHONPATH": str(REPO_ROOT), + "NO_COLOR": "1"} + command = (f"exec 8>&1; exec 1>/dev/null; exec 2>/dev/null; " + f"{shlex.quote(sys.executable)} -m daedalus") + result = subprocess.run(["bash", "-c", command], env=env, cwd=REPO_ROOT, + capture_output=True, text=True, check=False) + return [line.strip() for line in result.stdout.splitlines() if line.strip()] + + +@pytest.mark.skipif(os.name == "nt", reason="bash completion harness") +def test_completion_offers_the_script_name(): + """daedalus hello_ba completes hello_bash.""" + assert _probe("daedalus hello_ba") == ["hello_bash"] + + +@pytest.mark.skipif(os.name == "nt", reason="bash completion harness") +def test_completion_offers_the_help_words(): + """After the script name: only the help words (SPEC item 3.13.5.2).""" + assert _probe("daedalus hello_bash ") == ["--help", "-h", "help"] + assert _probe("daedalus hello_bash --") == ["--help"] + assert _probe("daedalus test hello_bash ") == ["--help", "-h", "help"] diff --git a/daedalus/completions.py b/daedalus/completions.py index 2d05155..c3cb970 100644 --- a/daedalus/completions.py +++ b/daedalus/completions.py @@ -92,20 +92,49 @@ def _exec_delegate(command: str, argv: list[str], env: dict[str, str]) -> None: os.execve(command, argv, env) -def handles_script_args(execute=_exec_delegate) -> bool: +BASH_HELP_WORDS = ("--help", "-h", "help") + + +def implements_bash_interface(path) -> bool: + """True when the .sh sources daedalus_common.sh (SPEC items 6.10.1, 3.13.5.2).""" + try: + return "daedalus_common.sh" in path.read_text(encoding="utf-8") + except OSError: + return False + + +def _emit_candidates(candidates: list[str]) -> None: + """Write candidates on the completion channel (fd 8), argcomplete protocol.""" + ifs = os.environ.get("_ARGCOMPLETE_IFS", "\013") + try: + with os.fdopen(8, "w") as stream: + stream.write(ifs.join(candidates)) + except OSError: + pass + + +def handles_script_args(execute=_exec_delegate, emit=None) -> bool: """True when the completion belongs to the script's own args (SPEC item 3.13.5). A .py script is execed through its runner command with the completion - environment rewritten to start at the script name (SPEC item 3.13.5.1); - other suffixes get no candidates at all (SPEC item 3.13.5.2). + environment rewritten to start at the script name (SPEC item 3.13.5.1). + A .sh script with the interface completes the help words itself, written + on the completion channel without running the script (SPEC item 3.13.5.2); + other suffixes get no candidates at all. """ plan = script_args_delegation() if plan is None: return False - script, comp_line, tail = plan + script, _comp_line, tail = plan path = script.absolute_path if path.suffix.lower() == ".py" and path.is_file(): command = runners.python_command(path) - env = dict(os.environ, COMP_LINE=comp_line, COMP_POINT=str(len(comp_line))) + env = dict(os.environ, COMP_LINE=_comp_line, COMP_POINT=str(len(_comp_line))) execute(command[0], [*command, *tail], env) + elif path.suffix.lower() == ".sh" and implements_bash_interface(path): + partial = tail[-1] if tail else "" + candidates = [word for word in BASH_HELP_WORDS if word.startswith(partial)] + if emit is None: + emit = _emit_candidates + emit(candidates) return True diff --git a/daedalus/registry.py b/daedalus/registry.py index 43f0f7b..f840162 100644 --- a/daedalus/registry.py +++ b/daedalus/registry.py @@ -59,6 +59,11 @@ SCRIPTS: dict[str, Script] = { description="Print a hello line and the daedalus version", categories="test", ), + "hello_bash": Script( + path="bash/hello_bash.sh", + description="Sample bash script through the shared help() interface", + categories="test", + ), } """Every script daedalus can run (SPEC.md section 4).""" diff --git a/daedalus/tests/test_cli.py b/daedalus/tests/test_cli.py index bb4bb44..7dd16ee 100644 --- a/daedalus/tests/test_cli.py +++ b/daedalus/tests/test_cli.py @@ -150,7 +150,7 @@ def test_path_with_extra_words_is_a_usage_error(fake_registry, plain, capsys): assert "usage: daedalus --path " in capsys.readouterr().err -@pytest.mark.parametrize("installed, expected", [(True, "daedalus 1.2.3"), (False, "daedalus 0.3.0")]) +@pytest.mark.parametrize("installed, expected", [(True, "daedalus 1.2.3"), (False, "daedalus 0.4.0")]) def test_version(monkeypatch, capsys, installed, expected): """--version uses metadata or pyproject.toml in a checkout.""" def fake_version(_name): diff --git a/daedalus/tests/test_completions.py b/daedalus/tests/test_completions.py index c641f88..2eef947 100644 --- a/daedalus/tests/test_completions.py +++ b/daedalus/tests/test_completions.py @@ -183,12 +183,62 @@ def test_handles_false_without_script_word(fake_registry, monkeypatch): def test_main_delegates_before_parsing(fake_registry, monkeypatch, capsys): """main hands script-arg completion over before any parsing or running.""" from daedalus import cli - monkeypatch.setattr(completions, "handles_script_args", lambda execute=None: True) + monkeypatch.setattr(completions, "handles_script_args", lambda execute=None, emit=None: True) assert cli.main(["hello", "-x"]) == 0 assert capsys.readouterr().out == "" -def _probe(comp_line: str) -> str: +@pytest.fixture +def bash_interface_script(tmp_path, monkeypatch): + """An .sh script in a tmp dir that implements the interface (SPEC item 6.10).""" + path = tmp_path / "iface.sh" + path.write_text('#!/usr/bin/env bash\n' + '. "$(dirname "${BASH_SOURCE[0]}")/daedalus_common.sh"\n') + monkeypatch.setitem(registry.SCRIPTS, "iface", + registry.Script(str(path), "Bash script", categories="test")) + plain = registry.Script(str(tmp_path / "plain.sh"), "Plain", categories="test") + monkeypatch.setitem(registry.SCRIPTS, "plain_sh", plain) + return path + + +def test_bash_help_words_narrow_by_prefix(bash_interface_script, monkeypatch): + """The help words filter by the word being typed (SPEC item 3.13.5.2).""" + set_comp_line(monkeypatch, "daedalus iface ") + emitted = [] + assert completions.handles_script_args(execute=emitted.append, + emit=emitted.append) is True + assert emitted == [["--help", "-h", "help"]] + set_comp_line(monkeypatch, "daedalus iface -") + emitted.clear() + assert completions.handles_script_args(execute=emitted.append, + emit=emitted.append) is True + assert emitted == [["--help", "-h"]] + set_comp_line(monkeypatch, "daedalus iface he") + emitted.clear() + assert completions.handles_script_args(execute=emitted.append, + emit=emitted.append) is True + assert emitted == [["help"]] + + +def test_bash_without_interface_is_silent(bash_interface_script, monkeypatch): + """A .sh script that does not source the helper gets no candidates.""" + set_comp_line(monkeypatch, "daedalus plain_sh ") + emitted = [] + assert completions.handles_script_args(execute=emitted.append, + emit=emitted.append) is True + assert emitted == [] + + +def test_implements_bash_interface(bash_interface_script, tmp_path): + """Interface detection reads the script source for the helper (SPEC item 6.10.1).""" + assert completions.implements_bash_interface(bash_interface_script) is True + plain = tmp_path / "plain.sh" + assert completions.implements_bash_interface(plain) is False + missing = tmp_path / "missing.sh" + assert completions.implements_bash_interface(missing) is False + + +def _probe(comp_line: str, code: str = "") -> str: """Replay the argcomplete hook for comp_line and return the candidates.""" env = dict( os.environ, @@ -199,35 +249,57 @@ def _probe(comp_line: str) -> str: _ARGCOMPLETE_SHELL="bash", NO_COLOR="1", ) - command = f"exec 8>&1; exec 1>/dev/null; exec 2>/dev/null; {shlex.quote(sys.executable)} -m daedalus" + program = (f"{shlex.quote(sys.executable)} -c {shlex.quote(code)}" + if code else f"{shlex.quote(sys.executable)} -m daedalus") + command = f"exec 8>&1; exec 1>/dev/null; exec 2>/dev/null; {program}" result = subprocess.run(["bash", "-c", command], env=env, cwd=str(REPO_ROOT), capture_output=True, text=True, check=False) return result.stdout +requires_bash = pytest.mark.skipif(os.name == "nt", reason="bash completion harness") requires_argcomplete = pytest.mark.skipif( importlib.util.find_spec("argcomplete") is None, reason="end-to-end completion needs argcomplete", ) +@requires_bash +@requires_argcomplete +def test_end_to_end_bash_script_help_words(tmp_path): + """A registered interface .sh completes its help words through the hook.""" + script = tmp_path / "probe.sh" + script.write_text('#!/usr/bin/env bash\n' + '. "$(dirname "${BASH_SOURCE[0]}")/daedalus_common.sh"\n') + code = ("import sys\nfrom daedalus import cli, registry\n" + f"registry.SCRIPTS['probe'] = registry.Script({str(script)!r}, 'Probe'," + " categories='test')\n" + "sys.exit(cli.main())\n") + lines = [line.strip() for line in _probe("daedalus probe ", code).splitlines() + if line.strip()] + assert lines == ["--help", "-h", "help"] + + def _candidates(comp_line: str) -> list: """The candidate words from the argcomplete hook for comp_line.""" return [line.strip() for line in _probe(comp_line).splitlines() if line.strip()] +@requires_bash @requires_argcomplete def test_end_to_end_first_word(): - """daedalus h completes hello through the argcomplete protocol.""" - assert _candidates("daedalus h") == ["hello"] + """daedalus hel lists hello and hello_bash (same prefix).""" + assert _candidates("daedalus hel") == ["hello", "hello_bash"] +@requires_bash @requires_argcomplete def test_end_to_end_after_category_prefix(): - """daedalus test h completes hello (the sub parser case).""" - assert _candidates("daedalus test h") == ["hello"] + """daedalus test hel lists both scripts in the category.""" + assert _candidates("daedalus test hel") == ["hello", "hello_bash"] +@requires_bash @requires_argcomplete def test_end_to_end_empty_word_lists_only_candidates(): """On an empty word, only daedalus offers: options plus scripts and labels.""" @@ -236,6 +308,7 @@ def test_end_to_end_empty_word_lists_only_candidates(): assert ".md" not in " ".join(candidates) +@requires_bash @requires_argcomplete def test_end_to_end_options_for_dash_prefix(): """A word starting with - completes daedalus's options, not scripts (SPEC item 3.10).""" @@ -245,12 +318,14 @@ def test_end_to_end_options_for_dash_prefix(): assert "hello" not in candidates +@requires_bash @requires_argcomplete def test_end_to_end_after_script_name_offers_no_daedalus_candidates(): """daedalus hello delegates: hello's own options, none of daedalus's (SPEC item 3.13.5).""" assert _candidates("daedalus hello ") == ["-h", "--help"] +@requires_bash @requires_argcomplete def test_end_to_end_script_options_come_from_the_script(): """daedalus hello - delegates: hello's options, never daedalus's (3.13.5.1).""" @@ -261,6 +336,7 @@ def test_end_to_end_script_options_come_from_the_script(): assert "--path" not in candidates +@requires_bash @requires_argcomplete def test_end_to_end_delegation_through_category(): """daedalus test hello -- completes hello's --help through the prefix.""" diff --git a/pyproject.toml b/pyproject.toml index 60ff805..d8f0034 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "daedalus" -version = "0.3.0" +version = "0.4.0" description = "Template for daedalus: loose scripts in one repo, run with: daedalus [args...]" readme = "README.md" requires-python = ">=3.11" diff --git a/python/tests/test_hello.py b/python/tests/test_hello.py index 3ff3611..221402c 100644 --- a/python/tests/test_hello.py +++ b/python/tests/test_hello.py @@ -34,7 +34,7 @@ def test_app_version_falls_back_to_pyproject(monkeypatch): raise hello.importlib.metadata.PackageNotFoundError(_name) monkeypatch.setattr(hello.importlib.metadata, "version", not_found) - assert hello.app_version() == "0.3.0" + assert hello.app_version() == "0.4.0" def test_help_exits_zero(capsys):