Repository navigation
refactor(cli): use Cobra validation for parent commands - #694
Merged
lizhengfeng101 merged 3 commits intoAug 3, 2026
Merged
Conversation
Contributor
|
🔍 OpenCodeReview found 2 issue(s) in this PR.
|
Fixing inconsistent indentation Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Fix inconsistent indentation Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
kall
pushed a commit
to kall/open-code-review
that referenced
this pull request
Aug 14, 2026
Three breakage classes from the merge, in one unit because the build does not compile until all three are fixed: - Rewrite the old module path to github.com/alibaba/open-code-review in core_cmd.go, core_diff.go and core_diff_test.go (alibaba#526). - Replace the last stale helper call with the model.Diff method the branch extracted it into (internal/agent/agent.go). - Re-register the core command group as cobra.Command trees after main deleted cmd/opencodereview/flags.go in the Cobra migration (alibaba#625). The newOcrFlagSet-based parsing in five run helpers is gone; flags now bind through Flags() and the helpers take explicit parameters. Conventions carried over from the surrounding commands: the parent rejects unknown subcommands and prints help when bare (alibaba#660, alibaba#694); rule and prompt validate positional count through exactArgs so the error carries the command's own usage (alibaba#749, alibaba#892); repo and diff flags reuse the shared helpers; prompt phases are declared in ValidArgs for completion (alibaba#625). The manual dispatcher and its hand-written usage block are dropped -- Cobra owns both now -- and core_cmd_test.go trades its argv-slice calls for tests that exercise the wiring through rootCmd.
Githab-capibara
added a commit
to Githab-capibara/open-code-review
that referenced
this pull request
Sep 17, 2026
* refactor(cli): use Cobra validation for parent commands * Update cmd/opencodereview/delegate_cmd.go Fixing inconsistent indentation Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update cmd/opencodereview/config_cmd.go Fix inconsistent indentation Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
Description
Simplifies parent-command validation introduced in #660.
Parent commands now use Cobra’s built-in
cobra.NoArgsvalidator instead of manually checking for unexpected arguments. This preserves the non-zero error behavior for unknown subcommands while removing duplicated validation logic.The parent-command tests now use
rootCmddirectly, avoidingcloneRootCmdreparenting global Cobra command objects during tests.Type of Change
How Has This Been Tested?
make testpasses locallyVerified that:
Checklist
go fmt,go vet)Related Issues
Fixes #688