github.com/alecthomas/kong@v0.9.1-0.20240410131203-2ab5733f1179/_examples/shell/help/main.go (about) 1 package main 2 3 import ( 4 "fmt" 5 6 "github.com/alecthomas/kong" 7 ) 8 9 var cli struct { 10 Flag flagWithHelp `help:"Regular flag help"` 11 Echo commandWithHelp `cmd:"" help:"Regular command help"` 12 } 13 14 type flagWithHelp bool 15 16 func (f *flagWithHelp) Help() string { 17 return "🏁 additional flag help" 18 } 19 20 type commandWithHelp struct { 21 Msg argumentWithHelp `arg:"" help:"Regular argument help"` 22 } 23 24 func (c *commandWithHelp) Help() string { 25 return "🚀 additional command help" 26 } 27 28 type argumentWithHelp struct { 29 Msg string `arg:""` 30 } 31 32 func (f *argumentWithHelp) Help() string { 33 return "📣 additional argument help" 34 } 35 36 func main() { 37 ctx := kong.Parse(&cli, 38 kong.Name("help"), 39 kong.Description("An app demonstrating HelpProviders"), 40 kong.UsageOnError(), 41 kong.ConfigureHelp(kong.HelpOptions{ 42 Compact: true, 43 Summary: false, 44 })) 45 switch ctx.Command() { 46 case "echo <msg>": 47 fmt.Println(cli.Echo.Msg) 48 } 49 }