-
Notifications
You must be signed in to change notification settings - Fork 28
/
service.go
40 lines (33 loc) · 1 KB
/
service.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
package cmd
import (
"github.com/Sirupsen/logrus"
"github.com/kujtimiihoxha/gk/generator"
"github.com/spf13/cobra"
)
// serviceCmd represents the service command
var serviceCmd = &cobra.Command{
Use: "service",
Short: "Create the sceleton of a service",
Aliases: []string{"s", "svc"},
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
logrus.Error("You must provide a name for the service")
return
}
gen := generator.NewServiceGenerator()
err := gen.Generate(args[0])
if err != nil {
logrus.Error(err)
}
},
}
func init() {
newCmd.AddCommand(serviceCmd)
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// serviceCmd.PersistentFlags().String("foo", "", "A help for foo")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// serviceCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}