Skip to content

Commit

Permalink
renamed the init generator
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Sep 5, 2018
1 parent 45fe1dc commit 465ab1a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 37 deletions.
43 changes: 10 additions & 33 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@ import (
"context"

"github.com/gobuffalo/genny"
"github.com/gobuffalo/release/genny/goreleaser"
"github.com/gobuffalo/release/genny/init"
"github.com/gobuffalo/release/genny/makefile"
"github.com/gobuffalo/release/genny/release"
"github.com/gobuffalo/release/genny/initgen"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)

var initOptions = struct {
*init.Options
dryRun bool
force bool
mainFile string
versionFile string
*initgen.Options
dryRun bool
}{}

// initCmd represents the init command
Expand All @@ -30,41 +24,24 @@ var initCmd = &cobra.Command{
run = genny.DryRunner(context.Background())
}

if len(initOptions.versionFile) != 0 {
run.WithRun(release.WriteVersionFile(&release.Options{
VersionFile: initOptions.versionFile,
Version: "v0.0.1",
}))
}
g, err := makefile.New(&makefile.Options{
Force: initOptions.force,
VersionFile: initOptions.versionFile,
})
opts := initOptions.Options

gg, err := initgen.New(opts)
if err != nil {
return errors.WithStack(err)
}
run.With(g)
run.WithGroup(gg)

if len(initOptions.mainFile) != 0 {
g, err = goreleaser.New(&goreleaser.Options{
Force: initOptions.force,
MainFile: initOptions.mainFile,
})
if err != nil {
return errors.WithStack(err)
}
run.With(g)
}
return run.Run()
},
}

func init() {
rootCmd.AddCommand(initCmd)
initCmd.Flags().BoolVarP(&initOptions.dryRun, "dry-run", "d", false, "runs the generator dry")
initCmd.Flags().BoolVarP(&initOptions.force, "force", "f", false, "force files to overwrite existing ones")
initCmd.Flags().StringVarP(&initOptions.mainFile, "main-file", "m", "", "adds a .goreleaser.yml file (only for binary applications)")
initCmd.Flags().StringVarP(&initOptions.versionFile, "version-file", "v", "version.go", "path to a version file to maintain")
initCmd.Flags().BoolVarP(&initOptions.Force, "force", "f", false, "force files to overwrite existing ones")
initCmd.Flags().StringVarP(&initOptions.MainFile, "main-file", "m", "", "adds a .goreleaser.yml file (only for binary applications)")
initCmd.Flags().StringVarP(&initOptions.VersionFile, "version-file", "v", "version.go", "path to a version file to maintain")

// Here you will define your flags and configuration settings.

Expand Down
2 changes: 1 addition & 1 deletion genny/init/init.go → genny/initgen/init.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package init
package initgen

import (
"github.com/gobuffalo/genny"
Expand Down
2 changes: 1 addition & 1 deletion genny/init/init_test.go → genny/initgen/init_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package init
package initgen

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion genny/init/options.go → genny/initgen/options.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package init
package initgen

type Options struct {
VersionFile string
Expand Down
2 changes: 1 addition & 1 deletion release/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package release

const Version = "v1.0.13"
const Version = "v1.0.14"

0 comments on commit 465ab1a

Please sign in to comment.