parent
a0da5299fe
commit
27f68b1dc5
@ -10,10 +10,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var RecipeFetchCommand = &cobra.Command{
|
var RecipeFetchCommand = &cobra.Command{
|
||||||
Use: "fetch [recipe] [flags]",
|
Use: "fetch [recipe | --all] [flags]",
|
||||||
Aliases: []string{"f"},
|
Aliases: []string{"f"},
|
||||||
Short: "Fetch recipe(s)",
|
Short: "Clone recipe(s) locally",
|
||||||
Long: "Retrieves all recipes if no [recipe] argument is passed.",
|
|
||||||
Args: cobra.RangeArgs(0, 1),
|
Args: cobra.RangeArgs(0, 1),
|
||||||
ValidArgsFunction: func(
|
ValidArgsFunction: func(
|
||||||
cmd *cobra.Command,
|
cmd *cobra.Command,
|
||||||
@ -27,6 +26,14 @@ var RecipeFetchCommand = &cobra.Command{
|
|||||||
recipeName = args[0]
|
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 != "" {
|
if recipeName != "" {
|
||||||
r := internal.ValidateRecipe(args, cmd.Name())
|
r := internal.ValidateRecipe(args, cmd.Name())
|
||||||
if err := r.Ensure(false, false); err != nil {
|
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",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
@ -11,7 +11,7 @@ setup() {
|
|||||||
assert_success
|
assert_success
|
||||||
assert_not_exists "$ABRA_DIR/recipes/matrix-synapse"
|
assert_not_exists "$ABRA_DIR/recipes/matrix-synapse"
|
||||||
|
|
||||||
run $ABRA recipe fetch
|
run $ABRA recipe fetch --all
|
||||||
assert_success
|
assert_success
|
||||||
assert_exists "$ABRA_DIR/recipes/matrix-synapse"
|
assert_exists "$ABRA_DIR/recipes/matrix-synapse"
|
||||||
}
|
}
|
||||||
@ -25,3 +25,13 @@ setup() {
|
|||||||
assert_success
|
assert_success
|
||||||
assert_exists "$ABRA_DIR/recipes/matrix-synapse"
|
assert_exists "$ABRA_DIR/recipes/matrix-synapse"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "error if missing args/flags" {
|
||||||
|
run $ABRA recipe fetch
|
||||||
|
assert_failure
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "error if single recipe and --all" {
|
||||||
|
run $ABRA recipe fetch matrix-synapse --all
|
||||||
|
assert_failure
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user