forked from toolshed/abra
refactor!: migrate to urfave/cli v1
Better flexible flags handling.
This commit is contained in:
@ -1,24 +1,31 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/autocomplete"
|
||||
"coopcloud.tech/abra/pkg/client"
|
||||
"coopcloud.tech/abra/pkg/formatter"
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var appVolumeListCommand = &cli.Command{
|
||||
Name: "list",
|
||||
var appVolumeListCommand = cli.Command{
|
||||
Name: "list",
|
||||
Aliases: []string{"ls"},
|
||||
Flags: []cli.Flag{
|
||||
internal.DebugFlag,
|
||||
internal.NoInputFlag,
|
||||
},
|
||||
Before: internal.SubCommandBefore,
|
||||
Usage: "List volumes associated with an app",
|
||||
Aliases: []string{"ls"},
|
||||
BashComplete: autocomplete.AppNameComplete,
|
||||
Action: func(c *cli.Context) error {
|
||||
app := internal.ValidateApp(c)
|
||||
|
||||
volumeList, err := client.GetVolumes(c.Context, app.Server, app.Name)
|
||||
volumeList, err := client.GetVolumes(context.Background(), app.Server, app.Name)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
@ -45,7 +52,7 @@ var appVolumeListCommand = &cli.Command{
|
||||
},
|
||||
}
|
||||
|
||||
var appVolumeRemoveCommand = &cli.Command{
|
||||
var appVolumeRemoveCommand = cli.Command{
|
||||
Name: "remove",
|
||||
Usage: "Remove volume(s) associated with an app",
|
||||
Description: `
|
||||
@ -62,12 +69,15 @@ Passing "--force" will select all volumes for removal. Be careful.
|
||||
ArgsUsage: "<app>",
|
||||
Aliases: []string{"rm"},
|
||||
Flags: []cli.Flag{
|
||||
internal.DebugFlag,
|
||||
internal.NoInputFlag,
|
||||
internal.ForceFlag,
|
||||
},
|
||||
Before: internal.SubCommandBefore,
|
||||
Action: func(c *cli.Context) error {
|
||||
app := internal.ValidateApp(c)
|
||||
|
||||
volumeList, err := client.GetVolumes(c.Context, app.Server, app.Name)
|
||||
volumeList, err := client.GetVolumes(context.Background(), app.Server, app.Name)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
@ -89,7 +99,7 @@ Passing "--force" will select all volumes for removal. Be careful.
|
||||
volumesToRemove = volumeNames
|
||||
}
|
||||
|
||||
err = client.RemoveVolumes(c.Context, app.Server, volumesToRemove, internal.Force)
|
||||
err = client.RemoveVolumes(context.Background(), app.Server, volumesToRemove, internal.Force)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
@ -101,12 +111,12 @@ Passing "--force" will select all volumes for removal. Be careful.
|
||||
BashComplete: autocomplete.AppNameComplete,
|
||||
}
|
||||
|
||||
var appVolumeCommand = &cli.Command{
|
||||
var appVolumeCommand = cli.Command{
|
||||
Name: "volume",
|
||||
Aliases: []string{"vl"},
|
||||
Usage: "Manage app volumes",
|
||||
ArgsUsage: "<command>",
|
||||
Subcommands: []*cli.Command{
|
||||
Subcommands: []cli.Command{
|
||||
appVolumeListCommand,
|
||||
appVolumeRemoveCommand,
|
||||
},
|
||||
|
Reference in New Issue
Block a user