Skip to content

Commit 415989e

Browse files
authored
feat(cli): styled help page with herald-help module (#260)
* feat(cli): styled help page with herald-help module * fix(cli): use configured theme for help output instead of herald default
1 parent d73bffe commit 415989e

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ require (
99
github.com/charmbracelet/colorprofile v0.4.3
1010
github.com/goccy/go-yaml v1.19.2
1111
github.com/indaco/herald v0.13.0
12+
github.com/indaco/herald-help v0.1.0
13+
github.com/indaco/herald-help/urfave v0.1.0
1214
github.com/pelletier/go-toml/v2 v2.3.0
1315
github.com/tidwall/sjson v1.2.5
1416
github.com/urfave/cli/v3 v3.8.0

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
5252
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
5353
github.com/indaco/herald v0.13.0 h1:+xVG9Fx5NpuWhwku/9IlRL6I009NnX4VUGKvlZHTRxU=
5454
github.com/indaco/herald v0.13.0/go.mod h1:T5g1+XLYvpjouhzAGHnAHDCKizhESkoV6+QPZ3DhgWA=
55+
github.com/indaco/herald-help v0.1.0 h1:JsEmFxRRShDtANGVz+/ZmPjEIiQOKtMNI0E3pe+lyeY=
56+
github.com/indaco/herald-help v0.1.0/go.mod h1:mnoL86+af5sKcdRJYlzDxjo777C46pHOsqnYMHTSHU0=
57+
github.com/indaco/herald-help/urfave v0.1.0 h1:GzoKYGbTxrrRlHkl7f0xWx7NxNH7Nukb2sMAH01PVzM=
58+
github.com/indaco/herald-help/urfave v0.1.0/go.mod h1:7hOLaKl7Y+8HZZ6NEjAy2bbZ/pEyzJO2hI/geJhbD4c=
5559
github.com/lucasb-eyer/go-colorful v1.4.0 h1:UtrWVfLdarDgc44HcS7pYloGHJUjHV/4FwW4TvVgFr4=
5660
github.com/lucasb-eyer/go-colorful v1.4.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
5761
github.com/mattn/go-runewidth v0.0.21 h1:jJKAZiQH+2mIinzCJIaIG9Be1+0NR+5sz/lYEEjdM8w=

internal/cli/cli.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ package cli
33
import (
44
"context"
55
"fmt"
6+
"io"
67
"os"
78
"strings"
89

10+
heraldhelp "github.com/indaco/herald-help"
11+
heraldurfave "github.com/indaco/herald-help/urfave"
912
"github.com/indaco/sley/internal/commands/bump"
1013
"github.com/indaco/sley/internal/commands/changelog"
1114
"github.com/indaco/sley/internal/commands/discover"
@@ -29,6 +32,16 @@ var (
2932
themeFlag string
3033
)
3134

35+
func init() {
36+
urfavecli.HelpPrinter = func(w io.Writer, _ string, data any) {
37+
cmd, ok := data.(*urfavecli.Command)
38+
if !ok {
39+
return
40+
}
41+
_ = heraldhelp.RenderTo(w, printer.Typography(), heraldurfave.FromUrfave(cmd))
42+
}
43+
}
44+
3245
// New builds and returns the root CLI command,
3346
// configuring all subcommands and flags for the sley cli.
3447
func New(cfg *config.Config, registry *plugins.PluginRegistry) *urfavecli.Command {

0 commit comments

Comments
 (0)