Skip to content

Include hidden arguments in completion scripts#898

Open
Galileo927 wants to merge 2 commits into
apple:mainfrom
Galileo927:hidden-completion
Open

Include hidden arguments in completion scripts#898
Galileo927 wants to merge 2 commits into
apple:mainfrom
Galileo927:hidden-completion

Conversation

@Galileo927
Copy link
Copy Markdown

Summary

Fixes #733.

This updates shell completion script generation so that arguments, options, and flags with .hidden visibility are included in generated completion scripts, while .private arguments remain excluded.

The normal help visibility behavior is unchanged.

Changes

  • Include hidden arguments when building tool info for shell completion generation.
  • Keep private arguments excluded from Bash, Fish, and Zsh completion scripts.
  • Add regression tests for hidden/private visibility in generated completion scripts.
  • Update existing completion snapshots to include the hidden --verbose flag.

Testing

swift test --filter ArgumentParserUnitTests.CompletionScriptTests

Result:

Executed 9 tests, with 0 failures

Checklist

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the [Contribution Guidelines]
  • I've updated the documentation if necessary

Copilot AI review requested due to automatic review settings May 17, 2026 17:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 includeHiddenArguments path 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?
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.

Include hidden args in completion scripts

2 participants