-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Description
Hi there,
i just tried to follow one of your examples, specifically the "ginger-crouton" example for the bool flag.
what i don't understand is why this example doesn't work for me. I could not find any other documentation on the bool flags, so right now i don't know how to figure out how to design and use bool flags.
Do you have another example or some other documentation at hand?
The code
package main
import (
"log"
"os"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Flags = []cli.Flag{
cli.BoolTFlag{
Name: "ginger-crouton",
Usage: "is it in the soup?",
},
}
app.Action = func(ctx *cli.Context) error {
if !ctx.Bool("ginger-crouton") {
return cli.NewExitError("it is not in the soup", 86)
}
return nil
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}
Metadata
Metadata
Assignees
Labels
No labels