diff --git a/bin/gcg b/bin/gcg index bd23e42..c9a52cc 100755 Binary files a/bin/gcg and b/bin/gcg differ diff --git a/bin/gcg.exe b/bin/gcg.exe new file mode 100755 index 0000000..aa43563 Binary files /dev/null and b/bin/gcg.exe differ diff --git a/bin/gcg_x86.exe b/bin/gcg_x86.exe new file mode 100755 index 0000000..ce40baf Binary files /dev/null and b/bin/gcg_x86.exe differ diff --git a/compile b/compile new file mode 100755 index 0000000..9baa929 --- /dev/null +++ b/compile @@ -0,0 +1,9 @@ +#!/bin/sh +# CGO_ENABLED: 0 +# GOOS: darwin、freebsd、linux、windows +# GOARCH: 386、amd64、arm + +go build -o bin/gcg gcg.go +CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o bin/gcg.exe gcg.go +CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -o bin/gcg_x86.exe gcg.go + diff --git a/gcg.go b/gcg.go index 4336303..7f6b55a 100644 --- a/gcg.go +++ b/gcg.go @@ -10,6 +10,11 @@ import ( "text/template" ) +const ( + version = "0.0.2" + helpText = "Using `gcg []` to generate go file\nSuch as `gcg data.json` or `gcg data.json ../add.go`" +) + type arguments struct { PackageName string `json:"package"` ImportedPackage []interface{} `json:"import"` @@ -79,8 +84,13 @@ func main() { var outputFile *os.File switch len(os.Args) { case 1: - exitWhenFalse(false, "Using `gcg []` to generate go file\nSuch as `gcg data.json` or `gcg data.json ../add.go`") + exitWhenFalse(false, helpText) case 2: + if os.Args[1] == "-h" || os.Args[1] == "--help" { + exitWhenFalse(false, helpText) + } else if os.Args[1] == "-v" || os.Args[1] == "--version" { + exitWhenFalse(false, fmt.Sprintf("Go Code Generator version: %s\n", version)) + } inputFile = os.Args[1] outputFile = os.Stdout default: