feat(bonfire): Artisan help, examples, JSON listing and error hints

- help <command> and <command> --help print Description, Usage,
  Arguments, Options with defaults, Global options, Help and Examples
- Command.Examples and Command.Hidden (appended, additive); list --all
  shows hidden commands, list --format=json prints a bonfire.Listing
- CheckDocs reports commands lacking description, long help, examples or
  argument and option descriptions
- Error block with the ERROR badge, WithHint explanation and Try lines
  ({bin} replaced), cobra suggestions as Try, -v error chain, messages
  scrubbed by sunscreen; Reported errors print nothing and exit 1
This commit is contained in:
Jakub Zych
2026-10-21 12:21:24 +02:00
parent 80fae5c279
commit fb32886775
12 changed files with 1130 additions and 52 deletions

View File

@@ -7,7 +7,6 @@ import (
"strings"
"charm.land/fang/v2"
"github.com/charmbracelet/colorprofile"
"github.com/spf13/cobra"
)
@@ -50,10 +49,9 @@ func Execute(ctx context.Context, root *cobra.Command, args []string) int {
fang.WithoutManpage(),
fang.WithoutCompletions(),
fang.WithErrorHandler(func(w io.Writer, _ fang.Styles, err error) {
if cw, ok := w.(*colorprofile.Writer); ok {
// RenderError applies its own color profile.
w = cw.Forward
}
// fang hands over a colorprofile writer built from the
// environment only; RenderError unwraps it and applies
// --ansi and --no-ansi itself.
RenderError(w, name, err, g)
}),
)