Compare commits

...

3 Commits

Author SHA1 Message Date
2e37c14fc4 feat: include local recipes on auto-complete
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2025-08-18 10:11:41 +02:00
5957eb3e13 fix: don't ensure latest on auto-complete
See #567
2025-08-18 10:11:23 +02:00
6e5d09b374 feat: catalogue sync command 2025-08-18 10:11:09 +02:00
3 changed files with 31 additions and 1 deletions

View File

@ -19,6 +19,24 @@ import (
"github.com/spf13/cobra" "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{ var CatalogueGenerateCommand = &cobra.Command{
Use: "generate [recipe] [flags]", Use: "generate [recipe] [flags]",
Aliases: []string{"g"}, Aliases: []string{"g"},

View File

@ -134,6 +134,7 @@ func Run(version, commit string) {
catalogue.CatalogueCommand.AddCommand( catalogue.CatalogueCommand.AddCommand(
catalogue.CatalogueGenerateCommand, catalogue.CatalogueGenerateCommand,
catalogue.CatalogueSyncCommand,
) )
server.ServerCommand.AddCommand( server.ServerCommand.AddCommand(

View File

@ -3,6 +3,7 @@ package autocomplete
import ( import (
"fmt" "fmt"
"sort" "sort"
"strings"
"coopcloud.tech/abra/pkg/app" "coopcloud.tech/abra/pkg/app"
appPkg "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. // RecipeNameComplete completes recipe names.
func RecipeNameComplete() ([]string, cobra.ShellCompDirective) { func RecipeNameComplete() ([]string, cobra.ShellCompDirective) {
catl, err := recipe.ReadRecipeCatalogue(false) catl, err := recipe.ReadRecipeCatalogue(true)
if err != nil { if err != nil {
err := fmt.Sprintf("autocomplete failed: %s", err) err := fmt.Sprintf("autocomplete failed: %s", err)
return []string{err}, cobra.ShellCompDirectiveError 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 var recipeNames []string
for name := range catl { for name := range catl {
recipeNames = append(recipeNames, name) recipeNames = append(recipeNames, name)
} }
for _, recipeLocal := range localRecipes {
recipeNames = append(recipeNames, recipeLocal)
}
return recipeNames, cobra.ShellCompDirectiveDefault return recipeNames, cobra.ShellCompDirectiveDefault
} }