forked from toolshed/abra
faet: a draft version of the app ls command
This commit is contained in:
24
cli/app.go
24
cli/app.go
@ -5,13 +5,15 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"coopcloud.tech/abra/client"
|
||||
"coopcloud.tech/abra/config"
|
||||
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
"github.com/docker/cli/cli/command/idresolver"
|
||||
|
||||
"coopcloud.tech/abra/client"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/schultz-is/passgen"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@ -50,6 +52,24 @@ var appListCommand = &cli.Command{
|
||||
Name: "list",
|
||||
Aliases: []string{"ls"},
|
||||
Flags: []cli.Flag{StatusFlag, ServerFlag, TypeFlag},
|
||||
Action: func(c *cli.Context) error {
|
||||
// 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()
|
||||
tableCol := []string{"Name", "Type", "Server"}
|
||||
table := createTable(tableCol)
|
||||
for name, appFile := range apps {
|
||||
app, err := config.GetApp(apps, name)
|
||||
if err != nil {
|
||||
logrus.Fatal(err.Error())
|
||||
}
|
||||
tableRow := []string{name, app.Type, appFile.Server}
|
||||
table.Append(tableRow)
|
||||
}
|
||||
table.Render()
|
||||
return nil
|
||||
},
|
||||
}
|
||||
var appCheckCommand = &cli.Command{
|
||||
Name: "check",
|
||||
|
Reference in New Issue
Block a user