refactor: moving logging to command functions

easier to unit test our util commands like this
This commit is contained in:
2021-07-19 12:47:46 +01:00
parent bd9bc530d1
commit cfe2f70151
3 changed files with 42 additions and 25 deletions

View File

@ -56,7 +56,10 @@ var appListCommand = &cli.Command{
// FIXME: Needs to use flags
// TODO: Sorting of output to make servers in alphabetical
// Looks like sorting a 2d slice of strings might be messy though
apps := config.LoadAppFiles()
apps, err := config.LoadAppFiles()
if err != nil {
logrus.Fatal(err)
}
tableCol := []string{"Name", "Type", "Server"}
table := createTable(tableCol)
for name, appFile := range apps {

View File

@ -5,6 +5,7 @@ import (
"coopcloud.tech/abra/client"
"coopcloud.tech/abra/config"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
@ -18,13 +19,16 @@ var serverListCommand = &cli.Command{
dockerContextStore := client.NewDefaultDockerContextStore()
contexts, err := dockerContextStore.Store.List()
if err != nil {
panic(err)
logrus.Fatal(err)
}
tableColumns := []string{"Name", "Connection"}
table := createTable(tableColumns)
defer table.Render()
serverNames := config.ReadServerNames()
serverNames, err := config.ReadServerNames()
if err != nil {
logrus.Fatal(err)
}
for _, serverName := range serverNames {
var row []string