From 43191d3ea261cbbfc4e611d6a0dd3b1f65514902 Mon Sep 17 00:00:00 2001 From: Evan Fiordeliso Date: Sat, 11 Nov 2023 19:17:46 -0500 Subject: [PATCH] Fix subcommand footer in help menu --- command.go | 8 ++++++++ help.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/command.go b/command.go index bbe4600..6395ceb 100644 --- a/command.go +++ b/command.go @@ -38,6 +38,14 @@ func (c *Command) ApplyOptions(options ...Option) { } } +func (c *Command) Root() *Command { + if c.isRoot { + return c + } + + return c.parent.Root() +} + func (c *Command) CommandPath() string { if c.parent == nil { return filepath.Base(os.Args[0]) diff --git a/help.go b/help.go index 55c91a9..f6d8de9 100644 --- a/help.go +++ b/help.go @@ -58,6 +58,6 @@ func (c *Command) ShowHelp() { if len(c.subcommands) > 0 { fmt.Println() - fmt.Println("Run 'go-cli --help' for more information about a command.") + fmt.Printf("Run '%s --help' for more information about a command.\n", c.Root().CommandPath()) } }