Skip to content

Improve themed help and error output#382

Merged
kindermax merged 3 commits into
masterfrom
theming-improvement
Jul 8, 2026
Merged

Improve themed help and error output#382
kindermax merged 3 commits into
masterfrom
theming-improvement

Conversation

@kindermax

@kindermax kindermax commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Updates theme colors for the default and synthwave schemes.
  • Aligns styled error output to the left while preserving the padded ERROR badge.
  • Moves dependency command trees left with the rest of the error output.
  • Adds spacing between the EXAMPLES help title and rendered examples.

Why

The themed terminal output had inconsistent horizontal spacing: unknown-command errors, usage hints, and dependency trees were indented farther right than desired. The EXAMPLES heading also ran directly into the first example, unlike the USAGE section.

Impact

Users get more compact, consistently aligned styled help and error output. The ERROR badge keeps its left and right padding inside the colored background.

Validation

  • go run ./cmd/lets help test-bats shows a blank line after EXAMPLES.
  • /private/tmp/lets-indent-test ttt shows left-aligned styled errors with padded ERROR badge.
  • go test ./internal/cmd passes.
  • go test ./... currently fails in internal/theme: TestColorSchemeByName still expects the old default title color Ash, while this branch returns #0BF4F1 from the theme color update commit.

Summary by Sourcery

Improve alignment and theming of styled help and error output for CLI commands.

Bug Fixes:

  • Ensure a blank line appears between the EXAMPLES help title and its examples.
  • Left-align styled error output, including usage hints, unknown-command messages, and dependency trees, while keeping the padded ERROR badge.
  • Adjust dependency tree indentation so entries align consistently with other error content.

Enhancements:

  • Update default and synthwave color schemes to use brighter accent colors for titles, base background, commands, and flags.

Documentation:

  • Document help and error output fixes in the unreleased changelog.

@sourcery-ai

sourcery-ai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Aligns themed help and error output to the left, adds spacing after EXAMPLES in help, and updates default/synthwave color schemes, with tests and changelog adjusted to assert and document the new behavior.

Sequence diagram for updated styled error rendering alignment

sequenceDiagram
  participant errorRenderer
  participant errorOutput
  participant styles
  participant writer

  errorRenderer->>styles: ErrorText.UnsetMarginLeft()
  errorRenderer->>errorOutput: header()
  errorOutput->>styles: ErrorHeader.UnsetMarginLeft().String()
  errorOutput->>writer: writeln(styled_header)

  errorRenderer->>errorRenderer: renderMessage(errorText)
  errorRenderer->>errorRenderer: renderUsage(errorText)
  errorRenderer->>errorRenderer: renderDependencyTree(depErr)

  errorRenderer->>errorOutput: commandTreeTitle()
  errorOutput->>styles: Title.Margin(0,0).Padding(0,0)
  errorOutput->>writer: writeln(command_tree_title)

  errorRenderer->>writer: writeln(strings.Repeat("  ", i+1) + joint + styles.Program.Command.Render(name))
Loading

Sequence diagram for help examples spacing after EXAMPLES title

sequenceDiagram
  participant helpRenderer
  participant output
  participant writer

  helpRenderer->>output: sectionTitle(examples)
  helpRenderer->>output: blank()
  output->>writer: writeln("")

  loop for each example
    helpRenderer->>helpRenderer: render example within width
  end
Loading

File-Level Changes

Change Details Files
Help renderer now inserts a blank line after the EXAMPLES section title and asserts example content is present.
  • Extend help output test to require "EXAMPLES" followed by a blank line
  • Extend help output test to require at least one rendered example line
  • Insert a blank line after rendering the examples section title before iterating examples
internal/cmd/help_test.go
internal/cmd/help.go
Error rendering is adjusted so the ERROR badge retains inner padding but all error text, usage hints, and dependency trees start at the left margin without extra left margin.
  • Rename the error handler test to reflect removal of error text left margin rather than header padding
  • Configure ErrorText style with a margin-left in the test to simulate themed indentation
  • Unset ErrorHeader margin-left when writing the header so its visual padding begins at column zero
  • Add assertions that ERROR header begins at column zero and has no extra outer margin
  • Add assertions that usage hints and unknown-command text start at column zero
  • Unset ErrorText margin-left at render time to remove themed indentation
  • Remove left margin from the command tree title style so it aligns with other error text
  • Reduce base indentation for dependency chain rendering by one level so the tree is less indented
internal/cmd/help_test.go
internal/cmd/error.go
internal/cmd/testdata/TestErrorGolden/command_not_found.golden
internal/cmd/testdata/TestErrorGolden/command_not_found_with_suggestion.golden
internal/cmd/testdata/TestErrorGolden/dependency_chain.golden
internal/cmd/testdata/TestErrorGolden/dependency_single.golden
Default and synthwave color schemes use brighter accent colors for base background, titles, commands, flags, and program labels.
  • Introduce a lighter cyan color constant for default scheme
  • Use the lighter cyan for the Base and Title colors in the default scheme
  • Adjust Program color in the default scheme to use the previous base cyan for better contrast
  • Introduce a basePink color for the synthwave scheme
  • Apply basePink as the Base and Command foreground color in synthwave
  • Update Flag accent color in synthwave to use basePink for consistency
internal/theme/theme.go
Changelog documents the help EXAMPLES spacing fix and left-aligned styled error output.
  • Add a Fixed entry describing EXAMPLES title spacing
  • Add a Fixed entry describing left-aligned styled error output with preserved error badge
docs/docs/changelog.md
Minor executor test formatting tweak to align comments.
  • Realign inline comments in after-script error test for consistent formatting
internal/executor/execute_test.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@kindermax kindermax marked this pull request as ready for review July 8, 2026 19:33

@sourcery-ai sourcery-ai Bot left a comment

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.

Hey - I've left some high level feedback:

  • The new EXAMPLES\n\n assertion in help_test.go is fairly brittle to formatting changes (e.g., different line endings or future spacing tweaks); consider asserting the position of a blank line relative to the EXAMPLES heading instead of matching the exact substring.
  • The error alignment tests in TestErrorHandlerRemovesErrorTextLeftMargin rely on specific substrings/whitespace patterns; you might make them more resilient by splitting output into lines and asserting indentation per-line rather than using multiple Contains checks with embedded spaces.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `EXAMPLES\n\n` assertion in `help_test.go` is fairly brittle to formatting changes (e.g., different line endings or future spacing tweaks); consider asserting the position of a blank line relative to the `EXAMPLES` heading instead of matching the exact substring.
- The error alignment tests in `TestErrorHandlerRemovesErrorTextLeftMargin` rely on specific substrings/whitespace patterns; you might make them more resilient by splitting output into lines and asserting indentation per-line rather than using multiple `Contains` checks with embedded spaces.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@kindermax kindermax force-pushed the theming-improvement branch from 318de78 to ba33c77 Compare July 8, 2026 19:41
@kindermax kindermax merged commit c13cdd3 into master Jul 8, 2026
5 checks passed
@kindermax kindermax deleted the theming-improvement branch July 8, 2026 19:43
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.

1 participant