fix: register flag completion functions for config, log-dir, payload-dir, env#4413
Merged
fix: register flag completion functions for config, log-dir, payload-dir, env#4413
Conversation
…dir, env The previous implementation used MarkFlagFilename/MarkFlagDirname which set annotations but did not register completion functions retrievable via GetFlagCompletionFunc. Switch to RegisterFlagCompletionFunc so the completions are both functional and testable. Fixes TestRegisterFlagCompletions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates Cobra flag completion registration so that completion functions are explicitly registered (and therefore discoverable/testable via GetFlagCompletionFunc()), resolving failing completion-related tests.
Changes:
- Replaced
MarkFlagFilename/MarkFlagDirnameusage with explicitRegisterFlagCompletionFuncfor--config,--log-dir,--payload-dir, and--env. - Kept completion directives consistent with prior behavior (
FilterFileExtfor file extensions,FilterDirsfor directory completion).
Show a summary per file
| File | Description |
|---|---|
internal/cmd/flags.go |
Registers explicit completion funcs for file/dir flags to make completions functional and testable. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
This was referenced Apr 23, 2026
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.
Problem
TestRegisterFlagCompletionsfails becauseMarkFlagFilename/MarkFlagDirnameset flag annotations but don't register completion functions retrievable via Cobra'sGetFlagCompletionFunc().Fix
Replace annotation-based helpers with explicit
RegisterFlagCompletionFunccalls that return the same directives (ShellCompDirectiveFilterFileExtfor file flags,ShellCompDirectiveFilterDirsfor directory flags). This makes completions both functional and testable.Changes
internal/cmd/flags.go: Switch 4 flags fromMarkFlagFilename/MarkFlagDirnametoRegisterFlagCompletionFuncVerification
make agent-finishedpasses with all checks green.