49 lines
1.0 KiB
Go
49 lines
1.0 KiB
Go
package recipe
|
|
|
|
import (
|
|
"fmt"
|
|
"sort"
|
|
"strconv"
|
|
|
|
"coopcloud.tech/abra/cli/formatter"
|
|
"coopcloud.tech/abra/pkg/catalogue"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
var recipeListCommand = &cli.Command{
|
|
Name: "list",
|
|
Usage: "List available recipes",
|
|
Aliases: []string{"ls"},
|
|
Action: func(c *cli.Context) error {
|
|
catl, err := catalogue.ReadRecipeCatalogue()
|
|
if err != nil {
|
|
logrus.Fatal(err.Error())
|
|
}
|
|
|
|
recipes := catl.Flatten()
|
|
sort.Sort(catalogue.ByRecipeName(recipes))
|
|
|
|
tableCol := []string{"name", "category", "status", "healthcheck", "backups", "email", "SSO"}
|
|
table := formatter.CreateTable(tableCol)
|
|
|
|
for _, recipe := range recipes {
|
|
tableRow := []string{
|
|
recipe.Name,
|
|
recipe.Category,
|
|
strconv.Itoa(recipe.Features.Status),
|
|
recipe.Features.Healthcheck,
|
|
recipe.Features.Backups,
|
|
recipe.Features.Email,
|
|
recipe.Features.SSO,
|
|
}
|
|
table.Append(tableRow)
|
|
}
|
|
|
|
table.SetCaption(true, fmt.Sprintf("total recipes: %v", len(recipes)))
|
|
table.Render()
|
|
|
|
return nil
|
|
},
|
|
}
|