forked from toolshed/abra
@ -10,10 +10,9 @@ import (
|
||||
)
|
||||
|
||||
var RecipeFetchCommand = &cobra.Command{
|
||||
Use: "fetch [recipe] [flags]",
|
||||
Use: "fetch [recipe | --all] [flags]",
|
||||
Aliases: []string{"f"},
|
||||
Short: "Fetch recipe(s)",
|
||||
Long: "Retrieves all recipes if no [recipe] argument is passed.",
|
||||
Short: "Clone recipe(s) locally",
|
||||
Args: cobra.RangeArgs(0, 1),
|
||||
ValidArgsFunction: func(
|
||||
cmd *cobra.Command,
|
||||
@ -27,6 +26,14 @@ var RecipeFetchCommand = &cobra.Command{
|
||||
recipeName = args[0]
|
||||
}
|
||||
|
||||
if recipeName == "" && !fetchAllRecipes {
|
||||
log.Fatal("missing [recipe] or --all/-a")
|
||||
}
|
||||
|
||||
if recipeName != "" && fetchAllRecipes {
|
||||
log.Fatal("cannot use [recipe] and --all/-a together")
|
||||
}
|
||||
|
||||
if recipeName != "" {
|
||||
r := internal.ValidateRecipe(args, cmd.Name())
|
||||
if err := r.Ensure(false, false); err != nil {
|
||||
@ -50,3 +57,17 @@ var RecipeFetchCommand = &cobra.Command{
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
var (
|
||||
fetchAllRecipes bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
RecipeFetchCommand.Flags().BoolVarP(
|
||||
&fetchAllRecipes,
|
||||
"all",
|
||||
"a",
|
||||
false,
|
||||
"fetch all recipes",
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user