-
Notifications
You must be signed in to change notification settings - Fork 2
/
generate.go
44 lines (39 loc) · 1.22 KB
/
generate.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
package cmd
import (
"github.com/bitrise-io/bitrise-plugins-service/generators"
"github.com/spf13/cobra"
)
var (
configFilePath string
serviceType string
databaseDialect string
projectPath string
aws bool
)
var generateCmd = &cobra.Command{
Use: "generate",
Short: "Generate service app",
Long: `Generate service app`,
Example: `generate --type=api`,
RunE: generate,
Aliases: []string{"g"},
}
func init() {
rootCmd.AddCommand(generateCmd)
generateCmd.Flags().StringVar(&configFilePath, "config", "", "Path of config file")
generateCmd.Flags().StringVar(&serviceType, "type", "", "Type of the service")
generateCmd.Flags().StringVar(&databaseDialect, "db", "", "Generate database with dialect")
generateCmd.Flags().StringVar(&projectPath, "path", "", "Source controll path of your project (e.g. github.com/my-org/my-project)")
generateCmd.Flags().BoolVar(&aws, "aws", false, "Generate AWS specific components")
}
func generate(cmd *cobra.Command, args []string) error {
if serviceType == "api" {
return generators.GenerateAPI(generators.Config{
ProjectPath: projectPath,
DBDialect: databaseDialect,
AWS: aws,
ConfigFilePath: configFilePath,
})
}
return nil
}