Skip to content

Commit 99e4c31

Browse files
lvan100lianghuan
authored andcommitted
feat(main): add --version
1 parent aa65f26 commit 99e4c31

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

main.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"fmt"
45
"os"
56

67
"github.com/go-spring/gs-gen/gen"
@@ -12,20 +13,27 @@ const Version = "v0.0.1"
1213

1314
func main() {
1415
var (
16+
version bool
1517
server bool
1618
language string
1719
)
1820

1921
root := &cobra.Command{
2022
Use: "gs-gen",
21-
Short: "gs-gen is a http code gen tool",
23+
Short: "A http code gen tool",
2224
SilenceUsage: true,
2325
}
2426

27+
root.Flags().BoolVar(&version, "version", false, "show version")
2528
root.Flags().BoolVar(&server, "server", false, "gen server code or not")
2629
root.Flags().StringVar(&language, "lang", "go", "language, go/php/java")
2730

2831
root.RunE = func(cmd *cobra.Command, args []string) error {
32+
if version {
33+
fmt.Println(root.Short)
34+
fmt.Println(Version)
35+
return nil
36+
}
2937
config := &generator.Config{
3038
ProjectDir: ".",
3139
Server: server,

0 commit comments

Comments
 (0)