-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (44 loc) · 1 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
package main
import (
"fmt"
"go.bbkane.com/warg"
"go.bbkane.com/warg/command"
"go.bbkane.com/warg/flag"
"go.bbkane.com/warg/section"
"go.bbkane.com/warg/value/scalar"
)
func app() *warg.App {
app := warg.New(
"butler",
section.New(
section.HelpShort("A virtual assistant"),
section.Command(
"present",
"Formally present a guest (guests are never introduced, always presented).",
present,
command.Flag(
"--name",
"Guest to address.",
scalar.String(),
flag.Alias("-n"),
flag.EnvVars("BUTLER_PRESENT_NAME", "USER"),
flag.Required(),
),
),
section.ExistingCommand("version", warg.VersionCommand()),
section.ExistingFlag("--color", warg.ColorFlag()),
),
warg.SkipValidation(),
)
return &app
}
func present(ctx command.Context) error {
// this is a required flag, so we know it exists
name := ctx.Flags["--name"].(string)
fmt.Fprintf(ctx.Stdout, "May I present to you %s.\n", name)
return nil
}
func main() {
app := app()
app.MustRun()
}