abra/cli/recipe/fetch.go
decentral1se 3dc5662821
All checks were successful
continuous-integration/drone/push Build is passing
fix: improved offline support
Closes coop-cloud/organising#471.
2023-07-26 08:16:07 +02:00

45 lines
1.0 KiB
Go

package recipe
import (
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/autocomplete"
"coopcloud.tech/abra/pkg/recipe"
"coopcloud.tech/abra/pkg/runtime"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
var recipeFetchCommand = cli.Command{
Name: "fetch",
Usage: "Fetch recipe local copies",
Aliases: []string{"f"},
ArgsUsage: "[<recipe>]",
Description: "Fetchs all recipes without arguments.",
Flags: []cli.Flag{
internal.DebugFlag,
internal.OfflineFlag,
},
Before: internal.SubCommandBefore,
BashComplete: autocomplete.RecipeNameComplete,
Action: func(c *cli.Context) error {
conf := runtime.New(runtime.WithOffline(internal.Offline))
recipeName := c.Args().First()
if recipeName != "" {
internal.ValidateRecipe(c, conf)
return nil // ValidateRecipe ensures latest checkout
}
repos, err := recipe.ReadReposMetadata(conf)
if err != nil {
logrus.Fatal(err)
}
if err := recipe.UpdateRepositories(repos, recipeName, conf); err != nil {
logrus.Fatal(err)
}
return nil
},
}