forked from toolshed/abra
		
	
		
			
				
	
	
		
			45 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			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
 | 
						|
	},
 | 
						|
}
 |