refactor: centralise recipe validation

This commit is contained in:
2021-09-06 00:45:13 +02:00
parent 691a2c7a50
commit a0625bf133
8 changed files with 14 additions and 12 deletions

View File

@ -1,7 +1,6 @@
package recipe
import (
"errors"
"fmt"
"os"
"path"
@ -20,10 +19,7 @@ var recipeCreateCommand = &cli.Command{
Aliases: []string{"c"},
ArgsUsage: "<recipe>",
Action: func(c *cli.Context) error {
recipe := c.Args().First()
if recipe == "" {
internal.ShowSubcommandHelpAndError(c, errors.New("no recipe provided"))
}
recipe := internal.ValidateRecipe(c)
directory := path.Join(config.APPS_DIR, recipe)
if _, err := os.Stat(directory); !os.IsNotExist(err) {