forked from toolshed/abra
feat: abra server ls
WE DID IT! The first actual command to be ported. Code is still a mess in terms of UX but its a milestone!
This commit is contained in:
@ -3,6 +3,8 @@ package cli
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"coopcloud.tech/abra/client"
|
||||
"coopcloud.tech/abra/config"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@ -12,6 +14,33 @@ var serverListCommand = &cli.Command{
|
||||
Usage: "List locally-defined servers.",
|
||||
ArgsUsage: emptyArgsUsage,
|
||||
HideHelp: true,
|
||||
Action: func(c *cli.Context) error {
|
||||
dockerContextStore := client.NewDefaultDockerContextStore()
|
||||
contexts, err := dockerContextStore.Store.List()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
tableColumns := []string{"Name", "Connection"}
|
||||
table := createTable(tableColumns)
|
||||
defer table.Render()
|
||||
|
||||
serverNames := config.ReadServerNames()
|
||||
for _, serverName := range serverNames {
|
||||
var row []string
|
||||
for _, ctx := range contexts {
|
||||
if ctx.Name == serverName {
|
||||
row = []string{serverName, client.GetContextEndpoint(ctx)}
|
||||
}
|
||||
}
|
||||
if len(row) == 0 {
|
||||
row = []string{serverName, "UNKNOWN"}
|
||||
}
|
||||
table.Append(row)
|
||||
|
||||
}
|
||||
return nil
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
var serverAddCommand = &cli.Command{
|
||||
|
Reference in New Issue
Block a user