Skip to content

Print a completion script whatever the commands above it ask for - #76

Merged
aoreshkov merged 1 commit into
mainfrom
cli-kit-completion-unconditional
Nov 6, 2026
Merged

aoreshkov merged 1 commit into
mainfrom
cli-kit-completion-unconditional

Conversation

@aoreshkov

Copy link
Copy Markdown
Owner

Summary

completion <shell> uses no option's value, but three things from the commands above it could stop it:

  • a required option: demo completion bash exits 2 with missing required option --store
  • an invalid value in an inherited option's variable
  • a constraint on a parent command, such as ExactlyOne

The parser already skipped settings for this command, so a broken configuration file couldn't stop it. It now returns right after reading the command's own command line, which covers all three and the settings with one check. Program was already answering completion without a handler.

completion is still held to its own command line: a missing or unknown shell is a usage error, and so is an invalid value typed on it. Other commands are held to everything as before.

There's no public API change.

Testing

  • ProgramTest: the new test covers all three cases and failed before the fix with missing required option --store. It also checks that go on the same programs still exits with a usage error. A second test covers completion's own command line.
  • ./gradlew check is green on Windows. The bash completion and SIGTERM tests are skipped there, so they need this PR's Linux job.
  • This PR and Pin what a program prints with golden files #75 touch nearby lines. A trial merge of the two has no conflicts and passes :cli-kit:check and :cli-kit-testing:check, again on Windows only.

🤖 Generated with Claude Code

A required option on the root, an invalid value in an inherited option's
variable or a constraint on the root stopped `completion <shell>`, though it
uses no option's value. The parser now stops after its command line for that
command, as it already skipped the settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aoreshkov
aoreshkov force-pushed the cli-kit-completion-unconditional branch from 64e78f1 to 9db0da2 Compare November 6, 2026 18:12
@aoreshkov
aoreshkov merged commit eba411e into main Nov 6, 2026
7 checks passed
@aoreshkov
aoreshkov deleted the cli-kit-completion-unconditional branch November 6, 2026 18:27
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.

1 participant