-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Simplify cli.NewExitError #475
Comments
ie, I would like to write: f, err := os.Create("config.yml")
if err != nil {
return err
}
defer f.Close()
err:= project.Configure(project.Slug, os.Stdin, f)
if err != nil {
return err
}
[...]
return nil instead. |
Hi @gravis, You can achieve this behavior yourself by doing something like: // define and instantiate a `cli.App`
err := app.Run(os.Args)
if err != nil {
fmt.Println(err)
os.Exit(1)
} I can see the argument that you are making though -- I think it makes sense, but would want to think through the drawbacks. Do you have thoughts about this @meatballhat (as the original implementer of this behavior 😄)? (It would basically just mean adding a default behavior to Lines 74 to 91 in 1d47add
|
Exactly was I was looking for. I wasn't obvious to me that the error was forwarded to |
Awesome! |
Hi,
I need to update a CLI tool because we have some deprecation warnings in the output.
While I thought I could simple return errors from commands, I end up with things like:
It would be so much easier to simply return
err
in case of error, and cli would display the error, and exit with code 1. Sounds like a very reasonable default, doesn't it?The text was updated successfully, but these errors were encountered: