Add proof of concept server ls comand
This commit is contained in:
parent
462a4d296f
commit
2e7da361a6
@ -2,6 +2,10 @@ package cli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
@ -12,6 +16,27 @@ var serverListCommand = &cli.Command{
|
|||||||
Usage: "List locally-defined servers.",
|
Usage: "List locally-defined servers.",
|
||||||
ArgsUsage: emptyArgsUsage,
|
ArgsUsage: emptyArgsUsage,
|
||||||
HideHelp: true,
|
HideHelp: true,
|
||||||
|
Action: func(c *cli.Context) error {
|
||||||
|
abradir := os.Getenv("HOME") + "/.abra"
|
||||||
|
|
||||||
|
servers, err := ioutil.ReadDir(abradir + "/servers")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
fmt.Println("\033[33mLoading status from", len(servers), "server(s), patience advised...\033[0m")
|
||||||
|
fmt.Println(len(servers), "servers:\n")
|
||||||
|
fmt.Println(" NAME\tCONNECTION")
|
||||||
|
fmt.Println(" --\t--")
|
||||||
|
for _, s := range servers {
|
||||||
|
conn, err := exec.Command("docker", "context", "inspect", s.Name(), "-f", "{{.Endpoints.docker.Host}}").Output()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
fmt.Printf(" %s\t%s\n", s.Name(), string(conn))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var serverAddCommand = &cli.Command{
|
var serverAddCommand = &cli.Command{
|
||||||
|
Reference in New Issue
Block a user