refactor!: cobra migrate
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-12-26 17:53:25 +01:00
parent 0df2b15c33
commit 671e1ca276
76 changed files with 12042 additions and 2545 deletions

View File

@ -1,7 +1,6 @@
package server
import (
"context"
"os"
"path/filepath"
@ -10,24 +9,27 @@ import (
"coopcloud.tech/abra/pkg/client"
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/log"
"github.com/urfave/cli/v3"
"github.com/spf13/cobra"
)
var serverRemoveCommand = cli.Command{
Name: "remove",
Aliases: []string{"rm"},
UsageText: "abra server remove <domain> [options]",
Usage: "Remove a managed server",
Description: `Remove a managed server.
var ServerRemoveCommand = &cobra.Command{
Use: "remove <server> [flags]",
Aliases: []string{"rm"},
Short: "Remove a managed server",
Long: `Remove a managed server.
Abra will remove the internal bookkeeping ($ABRA_DIR/servers/...) and
underlying client connection context. This server will then be lost in time,
like tears in rain.`,
Before: internal.SubCommandBefore,
ShellComplete: autocomplete.ServerNameComplete,
HideHelp: true,
Action: func(ctx context.Context, cmd *cli.Command) error {
serverName := internal.ValidateServer(cmd)
Args: cobra.ExactArgs(1),
ValidArgsFunction: func(
cmd *cobra.Command,
args []string,
toComplete string) ([]string, cobra.ShellCompDirective) {
return autocomplete.ServerNameComplete()
},
Run: func(cmd *cobra.Command, args []string) {
serverName := internal.ValidateServer(args)
if err := client.DeleteContext(serverName); err != nil {
log.Fatal(err)
@ -39,6 +41,6 @@ like tears in rain.`,
log.Infof("%s is now lost in time, like tears in rain", serverName)
return nil
return
},
}