Less confusing logging messages, clear "is created" / "already exists" output. Move the majority of logging to debug output to not confuse the situation. Some code cleanups also in there.
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package server
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"coopcloud.tech/abra/cli/internal"
|
|
"coopcloud.tech/abra/pkg/autocomplete"
|
|
"coopcloud.tech/abra/pkg/client"
|
|
"coopcloud.tech/abra/pkg/config"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var serverRemoveCommand = cli.Command{
|
|
Name: "remove",
|
|
Aliases: []string{"rm"},
|
|
ArgsUsage: "<server>",
|
|
Usage: "Remove a managed server",
|
|
Description: `Remove a managed server.
|
|
|
|
Abra will remove the internal bookkeeping (~/.abra/servers/...) and underlying
|
|
client connection context. This server will then be lost in time, like tears in
|
|
rain.
|
|
`,
|
|
Flags: []cli.Flag{
|
|
internal.DebugFlag,
|
|
internal.NoInputFlag,
|
|
internal.OfflineFlag,
|
|
},
|
|
Before: internal.SubCommandBefore,
|
|
BashComplete: autocomplete.ServerNameComplete,
|
|
Action: func(c *cli.Context) error {
|
|
serverName := internal.ValidateServer(c)
|
|
|
|
if err := client.DeleteContext(serverName); err != nil {
|
|
logrus.Fatal(err)
|
|
}
|
|
|
|
if err := os.RemoveAll(filepath.Join(config.SERVERS_DIR, serverName)); err != nil {
|
|
logrus.Fatal(err)
|
|
}
|
|
|
|
logrus.Infof("%s is now lost in time, like tears in rain", serverName)
|
|
|
|
return nil
|
|
},
|
|
}
|