refactor!: migrate to urfave/cli v1

Better flexible flags handling.
This commit is contained in:
2022-01-18 14:13:20 +01:00
parent c6db9ee355
commit 0e688f1407
48 changed files with 502 additions and 405 deletions

View File

@ -12,28 +12,31 @@ import (
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/config"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
"github.com/urfave/cli"
)
var restoreAllServices bool
var restoreAllServicesFlag = &cli.BoolFlag{
Name: "all",
Value: false,
Name: "all, a",
Destination: &restoreAllServices,
Aliases: []string{"a"},
Usage: "Restore all services",
}
var appRestoreCommand = &cli.Command{
Name: "restore",
Usage: "Restore an app from a backup",
Aliases: []string{"rs"},
Flags: []cli.Flag{restoreAllServicesFlag},
var appRestoreCommand = cli.Command{
Name: "restore",
Aliases: []string{"rs"},
Usage: "Restore an app from a backup",
Flags: []cli.Flag{
internal.DebugFlag,
internal.NoInputFlag,
restoreAllServicesFlag,
},
Before: internal.SubCommandBefore,
ArgsUsage: "<service> [<backup file>]",
Action: func(c *cli.Context) error {
app := internal.ValidateApp(c)
if c.Args().Len() > 1 && restoreAllServices {
if len(c.Args()) > 1 && restoreAllServices {
internal.ShowSubcommandHelpAndError(c, errors.New("cannot use <service>/<backup file> and '--all' together"))
}