refactor: use new internal arg failure func
This commit is contained in:
parent
43238d379c
commit
471c982f63
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 == "" {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue