-
Notifications
You must be signed in to change notification settings - Fork 1
fix: Display help text on stdout instead of stderr to prevent red color #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: #77
When running 'agent auth' without a subcommand, the help text is now ensured to be plain text by stripping any potential ANSI color codes. This prevents the help from appearing in red color in some terminals. Fixes #77
Added three test scripts to experiments folder: - test-auth-colors.sh: Demonstrates the original issue with help text on stderr - test-fix.sh: Validates that help text is now on stdout - test-actual-error.sh: Ensures errors still go to stderr appropriately These scripts help verify the fix and can be reused for regression testing.
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
|
How other CLI tools handle these cases? Is display of help is error or success? |
|
🤖 AI Work Session Started Starting automated work session at 2025-12-21T20:07:35.618Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback. |
Answer: Help display should go to STDOUT (success case)I researched how popular CLI tools handle this scenario. Here are the findings: Popular CLI Tools BehaviorWhen called without a subcommand, these tools display help on stdout: git → stdout: 2126 bytes, stderr: 0 bytes ✅ STDOUT
gh → stdout: 2442 bytes, stderr: 0 bytes ✅ STDOUT
npm → stdout: 1268 bytes, stderr: 0 bytes ✅ STDOUT
agent auth → stdout: 2242 bytes, stderr: 0 bytes ✅ STDOUT (after our fix)Invalid Subcommand vs No SubcommandCLI tools distinguish between these two cases: Case 1: No subcommand (user needs help)
Case 2: Invalid subcommand (actual error)
Why STDOUT is Correct
ConclusionHelp display is a success case - the tool is successfully showing the user what they need. Our fix aligns with how leading CLI tools (git, GitHub CLI, npm) handle this scenario. Full research findings are documented in |
Added comprehensive research findings on stdout vs stderr for help display: - Test scripts comparing popular CLI tools (git, gh, npm) - Research document with findings and recommendations - Evidence that our fix aligns with industry standards 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
Summary
Fixed the color issue with help text when calling
agent authwithout a subcommand.Problem
When running
agent authwithout specifying a subcommand (likelogin,logout, etc.), the help text was appearing in red color in terminals. This happened because the help text was being written to stderr usingconsole.error(), and many terminals display stderr output in red by default.Solution
Changed the fail handler in
src/index.jsto write validation errors and help text to stdout usingconsole.log()instead ofconsole.error(). This ensures the help text appears in normal color since it's informational, not an actual error.Additionally, the fix includes stripping ANSI color codes from the output using
stripAnsi()to ensure clean, colorless help text regardless of any formatting that yargs might apply.Research: Is Help Display an Error or Success?
To validate this approach, I researched how popular CLI tools handle this scenario:
Popular CLI Tools Behavior
Invalid Subcommand vs No Subcommand
Leading tools distinguish between:
Example with
git:git(no subcommand) → STDOUT (2126 bytes help text)git invalidcmd(invalid subcommand) → STDERR (61 bytes error)Conclusion
Our approach follows industry standards:
agent auth, they're seeking information, not encountering an errorSee detailed research findings in
experiments/cli-help-research/RESEARCH-FINDINGS.mdChanges
src/index.jsline 639-640: Changedconsole.error()toconsole.log()withstripAnsi()for validation error messages and help textexperiments/cli-help-research/folder to verify the fix and research CLI tool behaviorTesting
Verified that:
agent authnow goes to stdout (not stderr)auth,mcp, etc.)Fixes #77