refactor: use new internal arg failure func
This commit is contained in:
parent
43238d379c
commit
471c982f63
@ -1,6 +1,7 @@
|
|||||||
package recipe
|
package recipe
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@ -9,6 +10,7 @@ import (
|
|||||||
|
|
||||||
"coopcloud.tech/abra/catalogue"
|
"coopcloud.tech/abra/catalogue"
|
||||||
"coopcloud.tech/abra/cli/formatter"
|
"coopcloud.tech/abra/cli/formatter"
|
||||||
|
"coopcloud.tech/abra/cli/internal"
|
||||||
"coopcloud.tech/abra/config"
|
"coopcloud.tech/abra/config"
|
||||||
|
|
||||||
"github.com/go-git/go-git/v5"
|
"github.com/go-git/go-git/v5"
|
||||||
@ -46,7 +48,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 == "" {
|
||||||
return cli.ShowSubcommandHelp(c)
|
internal.ShowSubcommandHelpAndError(c, errors.New("no recipe provided"))
|
||||||
}
|
}
|
||||||
|
|
||||||
catalogue, err := catalogue.ReadAppsCatalogue()
|
catalogue, err := catalogue.ReadAppsCatalogue()
|
||||||
@ -81,7 +83,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 == "" {
|
||||||
return cli.ShowSubcommandHelp(c)
|
internal.ShowSubcommandHelpAndError(c, errors.New("no recipe provided"))
|
||||||
}
|
}
|
||||||
|
|
||||||
directory := path.Join(config.APPS_DIR, recipe)
|
directory := path.Join(config.APPS_DIR, recipe)
|
||||||
|
@ -2,9 +2,11 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
|
"coopcloud.tech/abra/cli/internal"
|
||||||
"coopcloud.tech/abra/client"
|
"coopcloud.tech/abra/client"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
@ -26,7 +28,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 == "" {
|
||||||
return cli.ShowSubcommandHelp(c)
|
internal.ShowSubcommandHelpAndError(c, errors.New("no host provided"))
|
||||||
}
|
}
|
||||||
|
|
||||||
cl, err := client.NewClientWithContext(host)
|
cl, err := client.NewClientWithContext(host)
|
||||||
|
@ -4,12 +4,14 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"coopcloud.tech/abra/cli/formatter"
|
"coopcloud.tech/abra/cli/formatter"
|
||||||
|
"coopcloud.tech/abra/cli/internal"
|
||||||
"github.com/hetznercloud/hcloud-go/hcloud"
|
"github.com/hetznercloud/hcloud-go/hcloud"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
@ -73,7 +75,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 == "" {
|
||||||
return cli.ShowSubcommandHelp(c)
|
internal.ShowSubcommandHelpAndError(c, errors.New("no name provided"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if hetznerCloudAPIToken == "" {
|
if hetznerCloudAPIToken == "" {
|
||||||
@ -176,7 +178,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 == "" {
|
||||||
return cli.ShowSubcommandHelp(c)
|
internal.ShowSubcommandHelpAndError(c, errors.New("no name provided"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if capsulAPIToken == "" {
|
if capsulAPIToken == "" {
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"coopcloud.tech/abra/cli/internal"
|
||||||
"coopcloud.tech/abra/client"
|
"coopcloud.tech/abra/client"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
@ -14,7 +17,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 == "" {
|
||||||
return cli.ShowSubcommandHelp(c)
|
internal.ShowSubcommandHelpAndError(c, errors.New("no server provided"))
|
||||||
}
|
}
|
||||||
if err := client.DeleteContext(server); err != nil {
|
if err := client.DeleteContext(server); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user