Skip to content

fix(cmd): hide usage help when command errors occur#120

Merged
bmahabirbu merged 1 commit intoopenkaiden:mainfrom
bmahabirbu:fix/hide-help-on-error
Mar 27, 2026
Merged

fix(cmd): hide usage help when command errors occur#120
bmahabirbu merged 1 commit intoopenkaiden:mainfrom
bmahabirbu:fix/hide-help-on-error

Conversation

@bmahabirbu
Copy link
Copy Markdown
Contributor

@bmahabirbu bmahabirbu commented Mar 27, 2026

Summary

  • Set SilenceUsage: true on the root command so Cobra never prints usage/help text alongside error messages
  • Removed redundant per-command SilenceUsage lines that were only active in JSON mode
  • Kept SilenceErrors in JSON mode to suppress the Error: prefix for clean JSON output

Before:

$ kortex-cli start aze
Error: workspace not found: aze
Use 'workspace list' to see available workspaces
Usage:
  kortex-cli start ID [flags]

Examples:
# Start workspace by ID
kortex-cli start abc123
...

After:

$ kortex-cli start aze
Error: workspace not found: aze
Use 'workspace list' to see available workspaces

Closes #102

Test plan

  • All existing tests pass (make test)
  • Verified error output no longer includes help text
  • Verify --help flag still shows usage as expected

🤖 Generated with Claude Code

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

Warning

Rate limit exceeded

@bmahabirbu has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 0 minutes and 52 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 0 minutes and 52 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c67abd70-5c78-4bce-829b-4dca8b680db3

📥 Commits

Reviewing files that changed from the base of the PR and between da77bab and 21ab24d.

📒 Files selected for processing (6)
  • pkg/cmd/init.go
  • pkg/cmd/root.go
  • pkg/cmd/workspace_list.go
  • pkg/cmd/workspace_remove.go
  • pkg/cmd/workspace_start.go
  • pkg/cmd/workspace_stop.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@feloy feloy left a comment

Choose a reason for hiding this comment

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

a little change in the comments, otherwise LGTM. Thanks

You will also need to sign-off the commit

pkg/cmd/init.go Outdated
// Silence Cobra's error and usage output when JSON mode is enabled
// This prevents "Error: ..." and usage info from being printed
// Silence Cobra's error output when JSON mode is enabled
// This prevents "Error: ..." prefix from being printed
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's not really the prefix being hidden, but the complete error message: cobra by default write the error returned by the command to stderr. In JSON, we don't to pollute the stream, because we are writing the error in the json

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That makes sense thanks!!

@bmahabirbu bmahabirbu force-pushed the fix/hide-help-on-error branch from 36cdb48 to c75d637 Compare March 27, 2026 06:43
Set SilenceUsage on the root command so Cobra never prints usage/help
text alongside error messages. Previously this was only done for JSON
output mode, leaving text-mode errors cluttered with the full help.

Closes kortex-hub#102

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Brian <bmahabir@bu.edu>
@bmahabirbu bmahabirbu force-pushed the fix/hide-help-on-error branch from c75d637 to 21ab24d Compare March 27, 2026 06:46
@bmahabirbu bmahabirbu merged commit 7029441 into openkaiden:main Mar 27, 2026
6 checks passed
bmahabirbu added a commit to bmahabirbu/kortex-cli that referenced this pull request Apr 1, 2026
Add AgentLister optional runtime interface so the info command discovers
agents generically instead of coupling to the Podman config package.
Remove the SilenceErrors block that is no longer needed since openkaiden#120.
Document the info command in the README and AgentLister in skills/CLAUDE.md.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

hide help when error occurs

3 participants