forked from toolshed/abra
.gitea
cli
cmd
pkg
app
autocomplete
autocomplete.go
client
compose
config
container
context
dns
formatter
git
integration
limit
lint
recipe
secret
server
service
ssh
upstream
web
scripts
tests
.drone.yml
.e2e.env.sample
.envrc.sample
.gitignore
.goreleaser.yml
Makefile
README.md
go.mod
go.sum
renovate.json
64 lines
951 B
Go
64 lines
951 B
Go
package autocomplete
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"coopcloud.tech/abra/pkg/config"
|
|
"coopcloud.tech/abra/pkg/recipe"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
// AppNameComplete copletes app names
|
|
func AppNameComplete(c *cli.Context) {
|
|
appNames, err := config.GetAppNames()
|
|
if err != nil {
|
|
logrus.Warn(err)
|
|
}
|
|
|
|
if c.NArg() > 0 {
|
|
return
|
|
}
|
|
|
|
for _, a := range appNames {
|
|
fmt.Println(a)
|
|
}
|
|
}
|
|
|
|
// RecipeNameComplete completes recipe names
|
|
func RecipeNameComplete(c *cli.Context) {
|
|
catl, err := recipe.ReadRecipeCatalogue()
|
|
if err != nil {
|
|
logrus.Warn(err)
|
|
}
|
|
|
|
if c.NArg() > 0 {
|
|
return
|
|
}
|
|
|
|
for name := range catl {
|
|
fmt.Println(name)
|
|
}
|
|
}
|
|
|
|
// SubcommandComplete completes subcommands.
|
|
func SubcommandComplete(c *cli.Context) {
|
|
if c.NArg() > 0 {
|
|
return
|
|
}
|
|
|
|
subcmds := []string{
|
|
"app",
|
|
"autocomplete",
|
|
"catalogue",
|
|
"recipe",
|
|
"record",
|
|
"server",
|
|
"upgrade",
|
|
}
|
|
|
|
for _, cmd := range subcmds {
|
|
fmt.Println(cmd)
|
|
}
|
|
}
|