Skip to content

Honor selected collections during shell completion - #1104

Open
2836048681 wants to merge 1 commit into
pyinvoke:mainfrom
2836048681:fix/238-complete-custom-collections
Open

2836048681 wants to merge 1 commit into
pyinvoke:mainfrom
2836048681:fix/238-complete-custom-collections

Conversation

@2836048681

Copy link
Copy Markdown

Fixes #238.

Bash and Fish pass the command being completed after --complete --. Invoke
currently loads the default task collection before considering that command's
-c/--collection option. Completion therefore suggests the wrong tasks, or
fails if there is no default task file.

Recover the collection with the existing core argument parser before loading
tasks. This supports spaced, equals-delimited and attached collection arguments
without adding shell-specific parsers. An explicit collection on the completion
process still takes precedence. Task-local -c flags remain task arguments,
and incomplete core flags retain the collection already parsed.

The generated shell scripts and ordinary task execution are unchanged. A
changelog entry credits the original reporter.

Validation on Linux, Python 3.12.3:

  • Full unit suite: 983 passed, 11 skipped.
  • CLI integration module: 18 passed, 4 skipped.
  • Ten new regression/control cases. Eight bug regressions fail against the
    unchanged upstream source at 6a71e680c535ba6520e935c497099fbca011d03c.
  • Generated scripts exercised with Bash 5.2.21 and Fish 3.7.0: 24/24 passed,
    including task and option completion, both presence and absence of default
    tasks, and task-local -c arguments. The same harness passes only the four
    controls on the upstream source; all twenty bug cases fail there.
  • MyPy 0.971: all 47 source files pass. Flake8, Black with the repository's
    79-column convention, compilation and committed-diff whitespace checks pass.

The test runner requires a controlling terminal for its terminal I/O tests;
the full unit suite was run under script with capture disabled. The selected
CLI integration module was run with an isolated home directory. There is one
existing pytest-relaxed deprecation warning, also seen on the baseline.
Other interpreters, operating systems, sudo integration, runner integration,
documentation builds and downstream projects were not tested.


Local submission handoff:

upstream 3.0 and main at review. Suggested target: 3.0.

  • Changed files: invoke/program.py, tests/completion.py,
    sites/www/changelog.rst — 62 insertions, 1 deletion.
  • Issue is open, unassigned, labeled Bug; the maintainer left Bash/Fish
    support open for contributions. Issue timeline, all-state issue-number PR
    search, completion PR search, and final open issue-number PR search show no
    competing collection completion fix. The owner has zero open repository PRs.
  • Screening: 17 eligible new candidates in shortlist.md; prior completed
    worker-01 repositories excluded. API responses are saved under screening/.
  • Ready package: ready/invoke-238/; test evidence: evidence/.
  • No push, pull request, comment, claim or GitHub authentication was made.

Reproduce from the checkout:

script -q -e -c '../.venv/bin/python -m pytest -q -s tests' ../evidence/full-after-script.log
PATH="$(realpath ../.venv/bin):$PATH" HOME="$(realpath ../evidence/test-home)" \
  script -q -e -c '../.venv/bin/python -m pytest -q -s integration/main.py' ../evidence/integration-main.log
../.venv/bin/mypy invoke
../.venv/bin/flake8 invoke/program.py tests/completion.py
../.venv/bin/black --check --line-length 79 invoke/program.py tests/completion.py
../.venv/bin/python ../evidence/check_shells.py
git diff HEAD^ HEAD --check

Placement limitation: ../ready-w01-r100.md, ../LEDGER-w01.md, and the
factory-wide ready/ledger destinations are read-only and outside this round's
writable root. This file and the append-ready LEDGER-w01.md are staged locally
for supervisor placement. See evidence/handoff-paths.json.

Fixes #238.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(non-zsh) completion scripts don't account for -c

1 participant