diff --git a/cli/recipe/recipe.go b/cli/recipe/recipe.go index 7214a0b7..c2b7bf34 100644 --- a/cli/recipe/recipe.go +++ b/cli/recipe/recipe.go @@ -1,6 +1,7 @@ package recipe import ( + "errors" "fmt" "os" "path" @@ -9,6 +10,7 @@ import ( "coopcloud.tech/abra/catalogue" "coopcloud.tech/abra/cli/formatter" + "coopcloud.tech/abra/cli/internal" "coopcloud.tech/abra/config" "github.com/go-git/go-git/v5" @@ -46,7 +48,7 @@ var recipeVersionCommand = &cli.Command{ Action: func(c *cli.Context) error { recipe := c.Args().First() if recipe == "" { - return cli.ShowSubcommandHelp(c) + internal.ShowSubcommandHelpAndError(c, errors.New("no recipe provided")) } catalogue, err := catalogue.ReadAppsCatalogue() @@ -81,7 +83,7 @@ var recipeCreateCommand = &cli.Command{ Action: func(c *cli.Context) error { recipe := c.Args().First() if recipe == "" { - return cli.ShowSubcommandHelp(c) + internal.ShowSubcommandHelpAndError(c, errors.New("no recipe provided")) } directory := path.Join(config.APPS_DIR, recipe) diff --git a/cli/server/init.go b/cli/server/init.go index f8c7f78b..f423844b 100644 --- a/cli/server/init.go +++ b/cli/server/init.go @@ -2,9 +2,11 @@ package server import ( "context" + "errors" "fmt" "net" + "coopcloud.tech/abra/cli/internal" "coopcloud.tech/abra/client" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" @@ -26,7 +28,7 @@ later for more advanced use cases. Action: func(c *cli.Context) error { host := c.Args().First() if host == "" { - return cli.ShowSubcommandHelp(c) + internal.ShowSubcommandHelpAndError(c, errors.New("no host provided")) } cl, err := client.NewClientWithContext(host) diff --git a/cli/server/new.go b/cli/server/new.go index a3e2f8c4..bc8c2215 100644 --- a/cli/server/new.go +++ b/cli/server/new.go @@ -4,12 +4,14 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" "io/ioutil" "net/http" "time" "coopcloud.tech/abra/cli/formatter" + "coopcloud.tech/abra/cli/internal" "github.com/hetznercloud/hcloud-go/hcloud" "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" @@ -73,7 +75,7 @@ environment variable or otherwise passing the "--env/-e" flag. Action: func(c *cli.Context) error { name := c.Args().First() if name == "" { - return cli.ShowSubcommandHelp(c) + internal.ShowSubcommandHelpAndError(c, errors.New("no name provided")) } if hetznerCloudAPIToken == "" { @@ -176,7 +178,7 @@ environment variable or otherwise passing the "--env/-e" flag. Action: func(c *cli.Context) error { name := c.Args().First() if name == "" { - return cli.ShowSubcommandHelp(c) + internal.ShowSubcommandHelpAndError(c, errors.New("no name provided")) } if capsulAPIToken == "" { diff --git a/cli/server/remove.go b/cli/server/remove.go index 4c14d73e..d1abb6d1 100644 --- a/cli/server/remove.go +++ b/cli/server/remove.go @@ -1,6 +1,9 @@ package server import ( + "errors" + + "coopcloud.tech/abra/cli/internal" "coopcloud.tech/abra/client" "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" @@ -14,7 +17,7 @@ var serverRemoveCommand = &cli.Command{ Action: func(c *cli.Context) error { server := c.Args().First() if server == "" { - return cli.ShowSubcommandHelp(c) + internal.ShowSubcommandHelpAndError(c, errors.New("no server provided")) } if err := client.DeleteContext(server); err != nil { logrus.Fatal(err)