-
-
Notifications
You must be signed in to change notification settings - Fork 142
/
Copy pathmain.go
52 lines (42 loc) · 1.03 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"fmt"
"github.com/alecthomas/kong"
)
var cli struct {
Flag flagWithHelp `help:"${flag_help}"`
Echo commandWithHelp `cmd:"" help:"Regular command help"`
}
type flagWithHelp bool
// See /~https://github.com/alecthomas/kong?tab=readme-ov-file#variable-interpolation
var vars = kong.Vars{
"flag_help": "Extended flag help that might be too long for directly " +
"including in the struct tag field",
}
type commandWithHelp struct {
Msg argumentWithHelp `arg:"" help:"Regular argument help"`
}
func (c *commandWithHelp) Help() string {
return "🚀 additional command help"
}
type argumentWithHelp struct {
Msg string `arg:""`
}
func (f *argumentWithHelp) Help() string {
return "📣 additional argument help"
}
func main() {
ctx := kong.Parse(&cli,
kong.Name("help"),
kong.Description("An app demonstrating HelpProviders"),
kong.UsageOnError(),
kong.ConfigureHelp(kong.HelpOptions{
Compact: true,
Summary: false,
}),
vars)
switch ctx.Command() {
case "echo <msg>":
fmt.Println(cli.Echo.Msg)
}
}