Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit code #820

Closed
yushion-yang opened this issue Jul 13, 2019 · 1 comment · Fixed by #823
Closed

Exit code #820

yushion-yang opened this issue Jul 13, 2019 · 1 comment · Fixed by #823
Assignees
Labels
kind/bug describes or fixes a bug kind/documentation describes a documentation update status/claimed someone has claimed this issue

Comments

@yushion-yang
Copy link

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)
}
}

the line of 13 should be cli.BoolFlag{ not cli.BoolTFlag{

@xordspar0
Copy link
Contributor

xordspar0 commented Aug 2, 2019

This is about the exit code section of the README.

I agree. The purpose of this example is to show that you can exit with an error code if a flag is unspecified, but with the code as it is, the only way to cause a non-zero exit is by adding the flag --ginger-crouton=false, which is not explained in the example.

I made a PR for this change: #823

@coilysiren coilysiren added status/claimed someone has claimed this issue kind/bug describes or fixes a bug kind/documentation describes a documentation update labels Aug 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug describes or fixes a bug kind/documentation describes a documentation update status/claimed someone has claimed this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants