feat: reorder subscriptions
This commit is contained in:
@ -1,6 +1,10 @@
|
||||
package cli
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func newSubscriptionCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
@ -17,6 +21,7 @@ func newSubscriptionCmd() *cobra.Command {
|
||||
newSubscriptionGetURLCmd(),
|
||||
newSubscriptionActivateCmd(),
|
||||
newSubscriptionDeactivateCmd(),
|
||||
newSubscriptionMoveCmd(),
|
||||
newSubscriptionListCmd(),
|
||||
newSubscriptionStorageCmd(),
|
||||
)
|
||||
@ -162,6 +167,37 @@ func newSubscriptionDeactivateCmd() *cobra.Command {
|
||||
}
|
||||
}
|
||||
|
||||
func newSubscriptionMoveCmd() *cobra.Command {
|
||||
var before, after string
|
||||
c := &cobra.Command{
|
||||
Use: "move <name> --before|--after <target>",
|
||||
Short: "Move a subscription before or after another in the list (affects display and config apply merge order)",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if (before == "") == (after == "") {
|
||||
return fmt.Errorf("specify exactly one of --before or --after")
|
||||
}
|
||||
|
||||
target := before
|
||||
isBefore := true
|
||||
if after != "" {
|
||||
target = after
|
||||
isBefore = false
|
||||
}
|
||||
|
||||
m, err := newManagers("", "", "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
m.Subscription.MoveSubscription(args[0], target, isBefore)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
c.Flags().StringVar(&before, "before", "", "Move the subscription immediately before this one")
|
||||
c.Flags().StringVar(&after, "after", "", "Move the subscription immediately after this one")
|
||||
return c
|
||||
}
|
||||
|
||||
func newSubscriptionListCmd() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "list",
|
||||
|
||||
Reference in New Issue
Block a user