forked from toolshed/abra
refactor(recipe): introduce new recipe struct and move some methods
This commit is contained in:
@ -24,9 +24,10 @@ var recipeFetchCommand = cli.Command{
|
||||
BashComplete: autocomplete.RecipeNameComplete,
|
||||
Action: func(c *cli.Context) error {
|
||||
recipeName := c.Args().First()
|
||||
r := recipe.Get2(recipeName)
|
||||
if recipeName != "" {
|
||||
internal.ValidateRecipe(c)
|
||||
if err := recipe.Ensure(recipeName); err != nil {
|
||||
if err := r.Ensure(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
return nil
|
||||
@ -39,7 +40,8 @@ var recipeFetchCommand = cli.Command{
|
||||
|
||||
catlBar := formatter.CreateProgressbar(len(catalogue), "fetching latest recipes...")
|
||||
for recipeName := range catalogue {
|
||||
if err := recipe.Ensure(recipeName); err != nil {
|
||||
r := recipe.Get2(recipeName)
|
||||
if err := r.Ensure(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
catlBar.Add(1)
|
||||
|
@ -28,23 +28,24 @@ var recipeLintCommand = cli.Command{
|
||||
BashComplete: autocomplete.RecipeNameComplete,
|
||||
Action: func(c *cli.Context) error {
|
||||
recipe := internal.ValidateRecipe(c)
|
||||
r := recipePkg.Get2(recipe.Name)
|
||||
|
||||
if err := recipePkg.EnsureExists(recipe.Name); err != nil {
|
||||
if err := r.EnsureExists(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if !internal.Chaos {
|
||||
if err := recipePkg.EnsureIsClean(recipe.Name); err != nil {
|
||||
if err := r.EnsureIsClean(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if !internal.Offline {
|
||||
if err := recipePkg.EnsureUpToDate(recipe.Name); err != nil {
|
||||
if err := r.EnsureUpToDate(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := recipePkg.EnsureLatest(recipe.Name); err != nil {
|
||||
if err := r.EnsureLatest(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -72,20 +72,21 @@ You may invoke this command in "wizard" mode and be prompted for input:
|
||||
BashComplete: autocomplete.RecipeNameComplete,
|
||||
Action: func(c *cli.Context) error {
|
||||
recipe := internal.ValidateRecipe(c)
|
||||
r := recipePkg.Get2(recipe.Name)
|
||||
|
||||
if err := recipePkg.EnsureIsClean(recipe.Name); err != nil {
|
||||
if err := r.EnsureIsClean(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := recipePkg.EnsureExists(recipe.Name); err != nil {
|
||||
if err := r.EnsureExists(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := recipePkg.EnsureUpToDate(recipe.Name); err != nil {
|
||||
if err := r.EnsureUpToDate(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := recipePkg.EnsureLatest(recipe.Name); err != nil {
|
||||
if err := r.EnsureLatest(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user