Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
2e37c14fc4
|
|||
5957eb3e13
|
|||
6e5d09b374
|
@ -19,6 +19,24 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var CatalogueSyncCommand = &cobra.Command{
|
||||
Use: "sync [flags]",
|
||||
Aliases: []string{"g"},
|
||||
Short: "Sync recipe catalogue for latest changes",
|
||||
Args: cobra.NoArgs,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if err := catalogue.EnsureCatalogue(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := catalogue.EnsureUpToDate(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Info("catalogue successfully synced")
|
||||
},
|
||||
}
|
||||
|
||||
var CatalogueGenerateCommand = &cobra.Command{
|
||||
Use: "generate [recipe] [flags]",
|
||||
Aliases: []string{"g"},
|
||||
|
@ -134,6 +134,7 @@ func Run(version, commit string) {
|
||||
|
||||
catalogue.CatalogueCommand.AddCommand(
|
||||
catalogue.CatalogueGenerateCommand,
|
||||
catalogue.CatalogueSyncCommand,
|
||||
)
|
||||
|
||||
server.ServerCommand.AddCommand(
|
||||
|
@ -3,6 +3,7 @@ package autocomplete
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"coopcloud.tech/abra/pkg/app"
|
||||
appPkg "coopcloud.tech/abra/pkg/app"
|
||||
@ -38,17 +39,27 @@ func ServiceNameComplete(appName string) ([]string, cobra.ShellCompDirective) {
|
||||
|
||||
// RecipeNameComplete completes recipe names.
|
||||
func RecipeNameComplete() ([]string, cobra.ShellCompDirective) {
|
||||
catl, err := recipe.ReadRecipeCatalogue(false)
|
||||
catl, err := recipe.ReadRecipeCatalogue(true)
|
||||
if err != nil {
|
||||
err := fmt.Sprintf("autocomplete failed: %s", err)
|
||||
return []string{err}, cobra.ShellCompDirectiveError
|
||||
}
|
||||
|
||||
localRecipes, err := recipe.GetRecipesLocal()
|
||||
if err != nil && !strings.Contains(err.Error(), "empty") {
|
||||
err := fmt.Sprintf("autocomplete failed: %s", err)
|
||||
return []string{err}, cobra.ShellCompDirectiveError
|
||||
}
|
||||
|
||||
var recipeNames []string
|
||||
for name := range catl {
|
||||
recipeNames = append(recipeNames, name)
|
||||
}
|
||||
|
||||
for _, recipeLocal := range localRecipes {
|
||||
recipeNames = append(recipeNames, recipeLocal)
|
||||
}
|
||||
|
||||
return recipeNames, cobra.ShellCompDirectiveDefault
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user