Include hidden arguments in shell completion scripts#900
Conversation
Arguments marked with `.hidden` visibility are part of the public API — they're just deprioritized in help output. Only `.private` arguments should be excluded from completions. Passes `includeHiddenArguments: true` when building `ToolInfoV0` for completion script generation, so hidden args appear in bash, fish, and zsh completions while private args remain excluded. Adds tests for all three shells verifying hidden args are present and private args are absent.
75901e6 to
073ea5c
Compare
|
I think there are still generated-script regressions in the snapshots after the separator fix. Several bash and fish fixtures now contain actual line breaks inside shell constructs that previously emitted escaped newline sequences, for example in There is also an escaping change in |
The previous commit introduced `'\''` which contains `\'`, an invalid escape sequence in Swift 6.2 — causing swift-format and the Swift compiler to fail with cascade parse errors from that line onward. Restore the correct `'\\''` (escaped backslash + two single quotes), which is the standard shell technique for embedding a literal single quote inside a single-quoted string. Regenerate completion snapshots: the invalid escape caused `$'\n'` sequences in generated bash scripts to appear as literal newlines in the previously-recorded snapshots; they are now correctly `$'\n'` again.
|
Thanks, the latest commit restores the |
Summary
Arguments marked with
.hiddenvisibility are currently excluded from shell completion scripts, along with.privatearguments. However, hidden arguments are still part of the public API — they're just deprioritized in help output. Only.privatearguments should be excluded from completions.This PR updates the completion script generation so that:
.hidden) are included in tab completions (bash, fish, zsh).private) remain excluded from completions--helpChanges
DumpHelpGenerator.swift: AddedincludeHiddenArgumentsparameter toToolInfoV0.init(commandStack:)andCommandInfoV0.init(commandStack:). Whentrue, setsshouldDisplay = truefor.hiddenarguments (in addition to.defaultones), so completion scripts include them.CompletionsGenerator.swift: PassincludeHiddenArguments: truewhen buildingToolInfoV0for completion script generation.--verboseflag from theBasetest command and the hidden--test-*flags from themathexample.testHiddenAndPrivate_Bash/Fish/Zshtest cases verifying hidden args appear in completions and private args don't.Testing
All 9 completion tests pass (including 3 new ones).
Fixes #733