diff --git a/command/command.go b/command/command.go index d0cab36..525dde3 100644 --- a/command/command.go +++ b/command/command.go @@ -39,6 +39,9 @@ type ( // NewCommand returns a new subcommand with direct command handling. NewCommand(name, usage string, f HandlerFunc) (sub Flag[Node]) + // PrintHelp prints a help message to the configured writer. + PrintHelp() + Flag[T] } ) diff --git a/command/help.go b/command/help.go index 0bcc15f..a373540 100644 --- a/command/help.go +++ b/command/help.go @@ -10,6 +10,8 @@ import ( var ErrHelp = errors.New("help requested") +func (n *node) PrintHelp() { _ = n.writeHelp() } + func (n *node) writeHelp() error { if _, err := fmt.Fprintf(n.out, "\nUsage:\t%s [-h | --help]%s COMMAND [OPTIONS]\n",