Support detailed help.

Any command/arg implementing the HelpProvider interface will be used to
provide arbitrarily detailed help.
This commit is contained in:
Alec Thomas
2018-08-14 14:41:27 +10:00
parent 27d2a08e53
commit f0bd1294a7
4 changed files with 31 additions and 5 deletions
+13 -4
View File
@@ -9,6 +9,16 @@ import (
"github.com/alecthomas/kong"
)
// nolint: govet
type threeArg struct {
RequiredThree bool `required`
Three string `arg`
}
func (threeArg) Help() string {
return `Detailed help provided through the HelpProvider interface.`
}
func TestHelp(t *testing.T) {
// nolint: govet
var cli struct {
@@ -26,10 +36,7 @@ func TestHelp(t *testing.T) {
Flag string `help:"Nested flag under two."`
RequiredTwo bool `required`
Three struct {
RequiredThree bool `required`
Three string `arg`
} `arg help:"Sub-sub-arg."`
Three threeArg `arg help:"Sub-sub-arg."`
Four struct {
} `cmd help:"Sub-sub-command."`
@@ -95,6 +102,8 @@ Run "test-app <command> --help" for more information on a command.
Sub-sub-arg.
Detailed help provided through the HelpProvider interface.
Flags:
--help Show context-sensitive help.
--string=STRING A string flag.