Skip to content

fix(io): print only help/data to stdout#4

Merged
btschwartz12 merged 1 commit intomainfrom
bschwartz/cleanup-stdout
Oct 17, 2025
Merged

fix(io): print only help/data to stdout#4
btschwartz12 merged 1 commit intomainfrom
bschwartz/cleanup-stdout

Conversation

@btschwartz12
Copy link
Contributor

@btschwartz12 btschwartz12 commented Oct 16, 2025

Currently, some errors/warnings are printed to stdout. This PR ensures anything that isn't data explicitly requested by the user (i.e. response data, command help) is printed to stderr.

Comment on lines 64 to +69
func (c *Command) HelpFunc(cmd *cobra.Command, _ []string) {
formatter.Println(rootHelpFunc(cmd))
formatter.Println(formatter.Stdout, rootHelpFunc(cmd))
}

func (c *Command) UsageFunc(cmd *cobra.Command, _ []string) {
formatter.Println(rootHelpFunc(cmd))
formatter.Println(formatter.Stderr, rootHelpFunc(cmd))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

By convention, Cobra will print help output to stdout (since the user explicitly requested it with the --help flag) and will print usage output (which only occurs during an error) to stderr.

We are overriding Cobra's built-in help/usage functions, so we should follow the same pattern.

@btschwartz12 btschwartz12 force-pushed the bschwartz/cleanup-stdout branch 3 times, most recently from 67816a4 to a74e7f1 Compare October 16, 2025 20:08
@censys censys deleted a comment from github-actions bot Oct 16, 2025
@btschwartz12 btschwartz12 force-pushed the bschwartz/cleanup-stdout branch from a74e7f1 to c8f89e2 Compare October 16, 2025 20:36
@github-actions
Copy link

📚 Documentation Reminder

This PR modifies command implementation files but doesn't update the corresponding documentation:

Action Required:

  • If your changes affect user-facing behavior (flags, output, functionality), please update the documentation files listed above.
  • If your changes are internal only (refactoring, bug fixes with no behavior change), you can safely ignore this message.

This is an automated check to help keep our documentation in sync with code changes.

@btschwartz12 btschwartz12 merged commit 82dcc55 into main Oct 17, 2025
6 checks passed
@btschwartz12 btschwartz12 deleted the bschwartz/cleanup-stdout branch October 17, 2025 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants