Skip to content

fix(help): normalize coloring, add doc links#7

Merged
btschwartz12 merged 2 commits intomainfrom
bschwartz/better-cmd-help
Oct 20, 2025
Merged

fix(help): normalize coloring, add doc links#7
btschwartz12 merged 2 commits intomainfrom
bschwartz/better-cmd-help

Conversation

@btschwartz12
Copy link
Contributor

No description provided.

@btschwartz12 btschwartz12 force-pushed the bschwartz/better-cmd-help branch 2 times, most recently from e0a6a19 to 25c9e4e Compare October 20, 2025 00:29
Copy link
Contributor Author

@btschwartz12 btschwartz12 Oct 20, 2025

Choose a reason for hiding this comment

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

This CI job was unnecessary to begin with. If we really want something for this, it can be added in the future

Comment on lines +67 to +79
if !formatter.StdoutIsTTY() {
restore := styles.TemporarilyDisableStyles()
defer restore()
}
formatter.Println(formatter.Stdout, rootHelpFunc(formatter.Stdout, cmd))
}

func (c *Command) UsageFunc(cmd *cobra.Command, _ []string) {
formatter.Println(formatter.Stderr, rootHelpFunc(cmd))
if !formatter.StderrIsTTY() {
restore := styles.TemporarilyDisableStyles()
defer restore()
}
formatter.Println(formatter.Stderr, rootHelpFunc(formatter.Stderr, 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.

This allows you to pipe help output to a file without all the nasty ANSI color sequences

![view](examples/view/view.gif)

You can also use the `--short` flag to render output using templates, which can be customized. See the [templating documentation](./docs/commands/view.md#templates) for more details.
You can also use the `--short` flag to render output using templates, which can be customized. See the [templating documentation](./docs/commands/VIEW.md#templates) for more details.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixing a broken link

@btschwartz12 btschwartz12 force-pushed the bschwartz/better-cmd-help branch 2 times, most recently from 83a65e5 to 2f397fd Compare October 20, 2025 00:45
Comment on lines -96 to -101
if cmd.HasAvailableSubCommands() {
b.WriteString("\n")
b.WriteString(styles.GlobalStyles.Secondary.Render("Use \""))
b.WriteString(styles.GlobalStyles.Signature.Render(cmd.CommandPath() + " [command] --help"))
b.WriteString(styles.GlobalStyles.Secondary.Render("\" for more information.") + "\n")
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is redundant

@btschwartz12 btschwartz12 force-pushed the bschwartz/better-cmd-help branch from 2f397fd to 98b3913 Compare October 20, 2025 00:49
@btschwartz12 btschwartz12 force-pushed the bschwartz/better-cmd-help branch from 98b3913 to 054b01f Compare October 20, 2025 12:02
@btschwartz12 btschwartz12 merged commit 1d4f796 into main Oct 20, 2025
5 checks passed
@btschwartz12 btschwartz12 deleted the bschwartz/better-cmd-help branch October 20, 2025 20:00
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.

3 participants