-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
58 lines (50 loc) · 1.63 KB
/
main.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
58
/*
This is a tool to generate client library for SonarQube (https://www.sonarqube.org/) web-api
It allows to generate client library based on your server version.
*/
package main
import (
"flag"
"log"
"os"
)
// flags
var (
host string
deprecated bool
internal bool
targetVersion string
help bool
out string
auth string
packageName string
templateDir string
)
var mainFlagsSet = flag.NewFlagSet("", flag.PanicOnError)
func parseFlags() {
mainFlagsSet.StringVar(&host, "host", "http://localhost:9000", "SonarQube server")
mainFlagsSet.BoolVar(&deprecated, "deprecated", false, "generate code for deprecated api methods (default: false)")
mainFlagsSet.BoolVar(&internal, "internal", false, "generate code for internal methods (default: false)")
mainFlagsSet.StringVar(&targetVersion, "target", "", "set target api version (default: server's version)")
mainFlagsSet.BoolVar(&help, "help", false, "show usage")
mainFlagsSet.StringVar(&out, "out", ".", "output directory")
mainFlagsSet.StringVar(&auth, "auth", "", "the header Authorization value,example: Basic YWRtaW46YWRtaW4=")
mainFlagsSet.StringVar(&packageName, "package", "", "package name, if not set will be sonarqube_client")
mainFlagsSet.StringVar(&templateDir, "template", "tpl", "template directory")
mainFlagsSet.Parse(os.Args[1:])
if help {
mainFlagsSet.Usage()
os.Exit(0)
}
}
func main() {
parseFlags()
var err error
var def *apiDefinition
if def, err = loadAPI(nil, host, deprecated, internal, targetVersion, auth); err != nil {
log.Fatal(err)
}
if err = generateCode(def, out); err != nil {
log.Fatal(err)
}
}