Skip to content

Commit 9a56d29

Browse files
committed
Match Basecamp CLI example styling
1 parent 0d10961 commit 9a56d29

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

internal/commands/help.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func renderRootHelp(cmd *cobra.Command, w io.Writer) {
111111

112112
if cmd.Example != "" {
113113
fmt.Fprintln(w)
114-
fmt.Fprintln(w, helpHeading(w, "EXAMPLES"))
114+
fmt.Fprintln(w, "EXAMPLES")
115115
printExampleBlock(w, cmd.Example)
116116
}
117117

@@ -170,7 +170,7 @@ func renderCommandHelp(cmd *cobra.Command, w io.Writer) {
170170

171171
if cmd.Example != "" {
172172
fmt.Fprintln(w)
173-
fmt.Fprintln(w, helpHeading(w, "EXAMPLES"))
173+
fmt.Fprintln(w, "EXAMPLES")
174174
printExampleBlock(w, cmd.Example)
175175
}
176176

@@ -336,18 +336,15 @@ func shouldShowDefault(f *pflag.Flag) bool {
336336
}
337337

338338
func printExampleBlock(w io.Writer, example string) {
339-
for _, line := range strings.Split(strings.TrimSpace(example), "\n") {
340-
fmt.Fprintf(w, " %s\n", line)
341-
}
342-
}
343-
344-
func helpHeading(w io.Writer, title string) string {
339+
style := lipgloss.NewStyle()
345340
if f, ok := w.(*os.File); ok {
346341
if isatty.IsTerminal(f.Fd()) || isatty.IsCygwinTerminal(f.Fd()) {
347-
return lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("12")).Render(title)
342+
style = lipgloss.NewStyle().Foreground(lipgloss.Color("12"))
348343
}
349344
}
350-
return title
345+
for _, line := range strings.Split(strings.TrimSpace(example), "\n") {
346+
fmt.Fprintf(w, "%s\n", style.Render(" "+line))
347+
}
351348
}
352349

353350
var rootCommandGroupsOrder = []string{"core", "collaboration", "admin", "utilities"}

0 commit comments

Comments
 (0)