forked from toolshed/abra
		
	refactor: deal with err from ShowSubcommandHelp
This commit is contained in:
		@ -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)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
@ -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()
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user