Include hidden arguments in completion scripts#898
Open
Galileo927 wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates completion script generation so .hidden arguments are included in Bash, Fish, and Zsh completions while .private arguments remain excluded.
Changes:
- Adds an
includeHiddenArgumentspath through tool info generation. - Enables hidden argument inclusion during completion script generation.
- Adds regression tests and updates completion snapshots for hidden flags.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Sources/ArgumentParser/Usage/DumpHelpGenerator.swift | Adds configurable hidden-argument inclusion when building tool info. |
| Sources/ArgumentParser/Completions/CompletionsGenerator.swift | Enables hidden arguments for Bash, Fish, and Zsh completion generation. |
| Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift | Filters private positional completions while preserving positional numbering. |
| Tests/ArgumentParserUnitTests/CompletionScriptTests.swift | Adds hidden/private visibility regression tests. |
| Tests/ArgumentParserUnitTests/Snapshots/testBase_Bash().bash | Updates Bash snapshot to include hidden --verbose. |
| Tests/ArgumentParserUnitTests/Snapshots/testBase_Fish().fish | Updates Fish snapshot to include hidden --verbose. |
| Tests/ArgumentParserUnitTests/Snapshots/testBase_Zsh().zsh | Updates Zsh snapshot to include hidden --verbose. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return ToolInfoV0(commandStack: [command]).fishCompletionScript | ||
| return ToolInfoV0( | ||
| commandStack: [command], | ||
| includeHiddenArguments: true |
| return ToolInfoV0(commandStack: [command]).zshCompletionScript | ||
| return ToolInfoV0( | ||
| commandStack: [command], | ||
| includeHiddenArguments: true |
Comment on lines
+174
to
+181
| help: ArgumentHelp("Hidden argument.", visibility: .hidden), | ||
| completion: .list(["hidden-argument-value"])) | ||
| var hiddenArgument: String? | ||
|
|
||
| @Argument( | ||
| help: ArgumentHelp("Private argument.", visibility: .private), | ||
| completion: .list(["private-argument-value"])) | ||
| var privateArgument: String? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #733.
This updates shell completion script generation so that arguments, options, and flags with
.hiddenvisibility are included in generated completion scripts, while.privatearguments remain excluded.The normal help visibility behavior is unchanged.
Changes
--verboseflag.Testing
swift test --filter ArgumentParserUnitTests.CompletionScriptTestsResult:
Checklist