forked from toolshed/abra
refactor: moved a lot of flags & added comments
Comments added to fix the golint errors on exported things need comments
This commit is contained in:
@ -4,12 +4,38 @@ import (
|
||||
"sort"
|
||||
|
||||
abraFormatter "coopcloud.tech/abra/cli/formatter"
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/config"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var status bool
|
||||
var statusFlag = &cli.BoolFlag{
|
||||
Name: "status",
|
||||
Aliases: []string{"S"},
|
||||
Value: false,
|
||||
Usage: "Show app deployment status",
|
||||
Destination: &status,
|
||||
}
|
||||
|
||||
var appType string
|
||||
var typeFlag = &cli.StringFlag{
|
||||
Name: "type",
|
||||
Aliases: []string{"t"},
|
||||
Value: "",
|
||||
Usage: "Show apps of a specific type",
|
||||
Destination: &appType,
|
||||
}
|
||||
|
||||
var listAppServer string
|
||||
var listAppServerFlag = &cli.StringFlag{
|
||||
Name: "server",
|
||||
Aliases: []string{"s"},
|
||||
Value: "",
|
||||
Usage: "Show apps of a specific server",
|
||||
Destination: &listAppServer,
|
||||
}
|
||||
|
||||
var appListCommand = &cli.Command{
|
||||
Name: "list",
|
||||
Usage: "List all managed apps",
|
||||
@ -22,9 +48,13 @@ actual live deployment status. Depending on how many servers you manage, this
|
||||
can take some time.
|
||||
`,
|
||||
Aliases: []string{"ls"},
|
||||
Flags: []cli.Flag{internal.StatusFlag, internal.ServerFlag, internal.TypeFlag},
|
||||
Flags: []cli.Flag{
|
||||
statusFlag,
|
||||
listAppServerFlag,
|
||||
typeFlag,
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
appFiles, err := config.LoadAppFiles(internal.Server)
|
||||
appFiles, err := config.LoadAppFiles(listAppServer)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
@ -37,7 +67,7 @@ can take some time.
|
||||
|
||||
statuses := map[string]string{}
|
||||
tableCol := []string{"Server", "Type", "Domain"}
|
||||
if internal.Status {
|
||||
if status {
|
||||
tableCol = append(tableCol, "Status")
|
||||
statuses, err = config.GetAppStatuses(appFiles)
|
||||
if err != nil {
|
||||
@ -50,10 +80,10 @@ can take some time.
|
||||
|
||||
for _, app := range apps {
|
||||
var tableRow []string
|
||||
if app.Type == internal.Type || internal.Type == "" {
|
||||
if app.Type == appType || appType == "" {
|
||||
// If type flag is set, check for it, if not, Type == ""
|
||||
tableRow = []string{app.File.Server, app.Type, app.Domain}
|
||||
if internal.Status {
|
||||
if status {
|
||||
if status, ok := statuses[app.StackName()]; ok {
|
||||
tableRow = append(tableRow, status)
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user