forked from toolshed/abra
refactor: autocomplete package
This commit is contained in:
42
pkg/autocomplete/autocomplete.go
Normal file
42
pkg/autocomplete/autocomplete.go
Normal file
@ -0,0 +1,42 @@
|
||||
package autocomplete
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"coopcloud.tech/abra/pkg/catalogue"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// 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 := catalogue.ReadRecipeCatalogue()
|
||||
if err != nil {
|
||||
logrus.Warn(err)
|
||||
}
|
||||
|
||||
if c.NArg() > 0 {
|
||||
return
|
||||
}
|
||||
|
||||
for name := range catl {
|
||||
fmt.Println(name)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user