From fe396b75370cc6993d50c1077814222b411dffc8 Mon Sep 17 00:00:00 2001 From: Kharec Date: Wed, 14 Jan 2026 13:00:03 +0100 Subject: [PATCH] feat: scope help printer to root command run --- cmd/goyco/cli.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/goyco/cli.go b/cmd/goyco/cli.go index ef72350..701387a 100644 --- a/cmd/goyco/cli.go +++ b/cmd/goyco/cli.go @@ -69,14 +69,14 @@ func printRunUsage() { func buildRootCommand(cfg *config.Config) *cli.Command { helpPrinterOnce.Do(func() { defaultHelpPrinter = cli.HelpPrinter - cli.HelpPrinter = func(w io.Writer, templ string, data interface{}) { - if cmd, ok := data.(*cli.Command); ok && cmd.Root() == cmd { - printRootUsage() - return - } - defaultHelpPrinter(w, templ, data) - } }) + cli.HelpPrinter = func(w io.Writer, templ string, data interface{}) { + if cmd, ok := data.(*cli.Command); ok && cmd.Root() == cmd { + printRootUsage() + return + } + defaultHelpPrinter(w, templ, data) + } root := &cli.Command{ Name: "goyco", @@ -94,6 +94,10 @@ func buildRootCommand(cfg *config.Config) *cli.Command { commands.SetJSONOutput(cmd.Bool("json")) return ctx, nil }, + After: func(ctx context.Context, cmd *cli.Command) error { + cli.HelpPrinter = defaultHelpPrinter + return nil + }, Action: func(_ context.Context, cmd *cli.Command) error { if cmd.NArg() == 0 { printRootUsage()