refactor: deal with err from ShowSubcommandHelp

This commit is contained in:
Roxie Gibson 2021-08-02 05:58:47 +01:00
parent bb1eb372ef
commit 9070806f8d
Signed by untrusted user: roxxers
GPG Key ID: 5D0140EDEE123F4D
5 changed files with 9 additions and 11 deletions

View File

@ -9,7 +9,10 @@ import (
// showSubcommandHelpAndError exits the program on error, logs the error to the terminal, and shows the help command.
func ShowSubcommandHelpAndError(c *cli.Context, err interface{}) {
cli.ShowSubcommandHelp(c)
if err2 := cli.ShowSubcommandHelp(c); err2 != nil {
// go-critic wants me to check this error but if this throws an error while we throw an error that would be annoying
logrus.Error(err2)
}
logrus.Error(err)
os.Exit(1)
}

View File

@ -46,8 +46,7 @@ var recipeVersionCommand = &cli.Command{
Action: func(c *cli.Context) error {
recipe := c.Args().First()
if recipe == "" {
cli.ShowSubcommandHelp(c)
return nil
return cli.ShowSubcommandHelp(c)
}
catalogue, err := catalogue.ReadAppsCatalogue()
@ -82,8 +81,7 @@ var recipeCreateCommand = &cli.Command{
Action: func(c *cli.Context) error {
recipe := c.Args().First()
if recipe == "" {
cli.ShowSubcommandHelp(c)
return nil
return cli.ShowSubcommandHelp(c)
}
directory := path.Join(config.APPS_DIR, recipe)

View File

@ -26,8 +26,7 @@ later for more advanced use cases.
Action: func(c *cli.Context) error {
host := c.Args().First()
if host == "" {
cli.ShowSubcommandHelp(c)
return nil
return cli.ShowSubcommandHelp(c)
}
cl, err := client.NewClientWithContext(host)

View File

@ -66,8 +66,7 @@ environment variable or otherwise passing the "--env/-e" flag.
Action: func(c *cli.Context) error {
name := c.Args().First()
if name == "" {
cli.ShowSubcommandHelp(c)
return nil
return cli.ShowSubcommandHelp(c)
}
ctx := context.Background()

View File

@ -14,8 +14,7 @@ var serverRemoveCommand = &cli.Command{
Action: func(c *cli.Context) error {
server := c.Args().First()
if server == "" {
cli.ShowSubcommandHelp(c)
return nil
return cli.ShowSubcommandHelp(c)
}
if err := client.DeleteContext(server); err != nil {
logrus.Fatal(err)