open-code-review/cmd/opencodereview
A ffebbf4f4b
fix(cli): return error on unknown subcommands for parent commands (#660)
Parent commands (session, config, delegate, llm, rules) were defined
without a RunE function. In Cobra, when a parent command has no RunE
and receives an unrecognized subcommand, it falls back to displaying
help and returns nil (exit 0). This is inconsistent with the root
command and leaf commands, which correctly return exit code 1 with an
error message.

Add RunE: func(cmd *cobra.Command, args []string) error { return cmd.Help() }
to all five parent commands so Cobra properly reports "unknown command"
errors instead of silently succeeding.

Includes tests verifying:
- unknown subcommands produce a non-nil error containing "unknown command"
- known subcommands still route correctly
- bare parent commands (no args) still print help and return nil

Closes #641
2026-08-03 16:23:02 +08:00
..
background_file.go fix(background-file) Manage path at git repository root directory Refs:#324 (#327) 2026-07-13 11:27:54 +08:00
background_file_test.go fix(background-file) Manage path at git repository root directory Refs:#324 (#327) 2026-07-13 11:27:54 +08:00
budget_output_test.go feat(manifest): run manifest coverage contract for review (#367) (#520) 2026-08-01 16:50:21 +08:00
compat_test.go feat(cli): add 'ocr session comments' to display saved review comments (#505) (#646) 2026-08-03 11:49:48 +08:00
completion.go refactor(cli): migrate to Cobra framework for shell completion support (#625) 2026-07-31 16:56:07 +08:00
config_cmd.go fix(cli): return error on unknown subcommands for parent commands (#660) 2026-08-03 16:23:02 +08:00
config_cmd_test.go refactor(test): remove config migration comments (#665) 2026-08-01 17:02:27 +08:00
config_dispatch_test.go test: improve coverage for cmd/opencodereview package from 42% to 70% 2026-06-27 01:47:48 +08:00
delegate_cmd.go fix(cli): return error on unknown subcommands for parent commands (#660) 2026-08-03 16:23:02 +08:00
emit_run_result_test.go feat(manifest): run manifest coverage contract for review (#367) (#520) 2026-08-01 16:50:21 +08:00
flag_suggest.go refactor(cli): migrate to Cobra framework for shell completion support (#625) 2026-07-31 16:56:07 +08:00
flags_test.go refactor(test): remove config migration comments (#665) 2026-08-01 17:02:27 +08:00
git.go fix(tool): resolve file_read paths against git top-level in monorepos (#309) 2026-07-07 20:06:28 +08:00
git_test.go test: fix golangci-lint errcheck/staticcheck issues in test code (#323) 2026-07-08 22:46:18 +08:00
llm_cmd.go fix(cli): return error on unknown subcommands for parent commands (#660) 2026-08-03 16:23:02 +08:00
main.go refactor(cli): migrate to Cobra framework for shell completion support (#625) 2026-07-31 16:56:07 +08:00
output.go feat(manifest): run manifest coverage contract for review (#367) (#520) 2026-08-01 16:50:21 +08:00
output_helpers_test.go feat(manifest): run manifest coverage contract for review (#367) (#520) 2026-08-01 16:50:21 +08:00
output_test.go fix: align Go module path with actual GitHub repository (#526) 2026-07-27 19:52:35 +08:00
parent_cmd_test.go fix(cli): return error on unknown subcommands for parent commands (#660) 2026-08-03 16:23:02 +08:00
procattr_unix.go feat: add standard MCP tool support (#212) 2026-07-01 19:10:16 +08:00
procattr_windows.go feat: add standard MCP tool support (#212) 2026-07-01 19:10:16 +08:00
provider_cmd.go fix: align Go module path with actual GitHub repository (#526) 2026-07-27 19:52:35 +08:00
provider_cmd_test.go test: fix golangci-lint errcheck/staticcheck issues in test code (#323) 2026-07-08 22:46:18 +08:00
provider_tui.go fix(cli): refocus previous input on esc in manual provider form (#630) 2026-08-01 11:28:39 +08:00
provider_tui_funcs_test.go fix: align Go module path with actual GitHub repository (#526) 2026-07-27 19:52:35 +08:00
provider_tui_test.go fix(cli): refocus previous input on esc in manual provider form (#630) 2026-08-01 11:28:39 +08:00
review_cmd.go feat(manifest): run manifest coverage contract for review (#367) (#520) 2026-08-01 16:50:21 +08:00
review_cmd_test.go feat(manifest): run manifest coverage contract for review (#367) (#520) 2026-08-01 16:50:21 +08:00
root.go refactor(cli): migrate to Cobra framework for shell completion support (#625) 2026-07-31 16:56:07 +08:00
rules_cmd.go fix(cli): return error on unknown subcommands for parent commands (#660) 2026-08-03 16:23:02 +08:00
scan_cmd.go refactor(cli): migrate to Cobra framework for shell completion support (#625) 2026-07-31 16:56:07 +08:00
scan_cmd_test.go refactor(cli): migrate to Cobra framework for shell completion support (#625) 2026-07-31 16:56:07 +08:00
session_cmd.go fix(cli): return error on unknown subcommands for parent commands (#660) 2026-08-03 16:23:02 +08:00
session_cmd_test.go feat(cli): add 'ocr session comments' to display saved review comments (#505) (#646) 2026-08-03 11:49:48 +08:00
shared.go feat(manifest): run manifest coverage contract for review (#367) (#520) 2026-08-01 16:50:21 +08:00
shared_flags.go feat(cli): add 'ocr session comments' to display saved review comments (#505) (#646) 2026-08-03 11:49:48 +08:00
shared_test.go fix: align Go module path with actual GitHub repository (#526) 2026-07-27 19:52:35 +08:00
shell_unix.go feat: add standard MCP tool support (#212) 2026-07-01 19:10:16 +08:00
shell_windows.go feat: add standard MCP tool support (#212) 2026-07-01 19:10:16 +08:00
smallfiles_test.go refactor(cli): migrate to Cobra framework for shell completion support (#625) 2026-07-31 16:56:07 +08:00
version.go refactor(cli): migrate to Cobra framework for shell completion support (#625) 2026-07-31 16:56:07 +08:00
viewer_cmd.go refactor(cli): migrate to Cobra framework for shell completion support (#625) 2026-07-31 16:56:07 +08:00