refactor: deal with err from ShowSubcommandHelp
This commit is contained in:
parent
bb1eb372ef
commit
9070806f8d
|
@ -9,7 +9,10 @@ import (
|
||||||
|
|
||||||
// showSubcommandHelpAndError exits the program on error, logs the error to the terminal, and shows the help command.
|
// showSubcommandHelpAndError exits the program on error, logs the error to the terminal, and shows the help command.
|
||||||
func ShowSubcommandHelpAndError(c *cli.Context, err interface{}) {
|
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)
|
logrus.Error(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,7 @@ var recipeVersionCommand = &cli.Command{
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
recipe := c.Args().First()
|
recipe := c.Args().First()
|
||||||
if recipe == "" {
|
if recipe == "" {
|
||||||
cli.ShowSubcommandHelp(c)
|
return cli.ShowSubcommandHelp(c)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
catalogue, err := catalogue.ReadAppsCatalogue()
|
catalogue, err := catalogue.ReadAppsCatalogue()
|
||||||
|
@ -82,8 +81,7 @@ var recipeCreateCommand = &cli.Command{
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
recipe := c.Args().First()
|
recipe := c.Args().First()
|
||||||
if recipe == "" {
|
if recipe == "" {
|
||||||
cli.ShowSubcommandHelp(c)
|
return cli.ShowSubcommandHelp(c)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
directory := path.Join(config.APPS_DIR, recipe)
|
directory := path.Join(config.APPS_DIR, recipe)
|
||||||
|
|
|
@ -26,8 +26,7 @@ later for more advanced use cases.
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
host := c.Args().First()
|
host := c.Args().First()
|
||||||
if host == "" {
|
if host == "" {
|
||||||
cli.ShowSubcommandHelp(c)
|
return cli.ShowSubcommandHelp(c)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cl, err := client.NewClientWithContext(host)
|
cl, err := client.NewClientWithContext(host)
|
||||||
|
|
|
@ -66,8 +66,7 @@ environment variable or otherwise passing the "--env/-e" flag.
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
name := c.Args().First()
|
name := c.Args().First()
|
||||||
if name == "" {
|
if name == "" {
|
||||||
cli.ShowSubcommandHelp(c)
|
return cli.ShowSubcommandHelp(c)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
|
@ -14,8 +14,7 @@ var serverRemoveCommand = &cli.Command{
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
server := c.Args().First()
|
server := c.Args().First()
|
||||||
if server == "" {
|
if server == "" {
|
||||||
cli.ShowSubcommandHelp(c)
|
return cli.ShowSubcommandHelp(c)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
if err := client.DeleteContext(server); err != nil {
|
if err := client.DeleteContext(server); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
|
|
Loading…
Reference in New Issue