-
Notifications
You must be signed in to change notification settings - Fork 4
/
init.go
57 lines (46 loc) · 1.63 KB
/
init.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package cmd
import (
"context"
"github.com/gobuffalo/genny"
"github.com/gobuffalo/release/genny/initgen"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
var initOptions = struct {
*initgen.Options
dryRun bool
}{
Options: &initgen.Options{},
}
// initCmd represents the init command
var initCmd = &cobra.Command{
Use: "init",
Short: "setups a project to use release",
RunE: func(cmd *cobra.Command, args []string) error {
var run *genny.Runner = genny.WetRunner(context.Background())
if initOptions.dryRun {
run = genny.DryRunner(context.Background())
}
opts := initOptions.Options
gg, err := initgen.New(opts)
if err != nil {
return errors.WithStack(err)
}
run.WithGroup(gg)
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")
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// initCmd.PersistentFlags().String("foo", "", "A help for foo")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// initCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}