0
0
forked from toolshed/abra

refactor: construct recipe struct proper

This commit is contained in:
2021-09-06 01:41:16 +02:00
parent 6a1ecd0f85
commit 356c8f8c4e
6 changed files with 26 additions and 33 deletions

View File

@ -12,19 +12,20 @@ import (
)
// ValidateRecipe ensures the recipe arg is valid.
func ValidateRecipe(c *cli.Context) string {
func ValidateRecipe(c *cli.Context) recipe.Recipe {
recipeName := c.Args().First()
if recipeName == "" {
ShowSubcommandHelpAndError(c, errors.New("no recipe provided"))
}
if err := recipe.EnsureExists(recipeName); err != nil {
recipe, err := recipe.Get(recipeName)
if err != nil {
logrus.Fatal(err)
os.Exit(1)
}
return recipeName
return recipe
}
// ValidateApp ensures the app name arg is valid.