-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
60 lines (49 loc) · 1.62 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
59
60
package main
import (
"github.com/jawher/mow.cli"
log "github.com/sirupsen/logrus"
"os"
)
func main() {
app := cli.App("az-rest", "A simple Azure Resource Manager REST client.")
app.Spec = "[-v]"
var (
verbose = app.BoolOpt("v verbose", false, "Verbose output mode")
)
app.Before = func() {
if *verbose {
log.SetLevel(log.DebugLevel)
} else {
log.SetLevel(log.InfoLevel)
}
}
app.Command("GET", "Issue a GET request", func(cmd *cli.Cmd) {
var (
apiVersion = cmd.StringOpt("a api-version", "", "The API version to use for each request. If not specified, latest version will be used.")
query = cmd.StringOpt("query", "", "A JMESPath query to filter the result.")
rawUrl = cmd.StringArg("URL", "", "The URL to invoke.")
)
cmd.Spec = "-a [--query] URL"
cmd.Action = func() {
ArmGet(*rawUrl, *apiVersion, *query)
}
})
app.Command("POST", "Issue a POST request", func(cmd *cli.Cmd) {
var (
apiVersion = cmd.StringOpt("a api-version", "", "The API version to use for each request. If not specified, latest version will be used.")
reqBody = cmd.StringOpt("body", "", "The body for the POST request.")
query = cmd.StringOpt("query", "", "A JMESPath query to filter the result.")
rawUrl = cmd.StringArg("URL", "", "The URL to invoke.")
)
cmd.Spec = "-a [--query] [--body] URL "
cmd.Action = func() {
ArmPost(*rawUrl, *apiVersion, *query, *reqBody)
}
})
app.Command("version", "Print version information", func(cmd *cli.Cmd) {
cmd.Action = func() {
log.Info("az-rest version: ", Version, " ", VersionPrerelease, " ", GitCommit)
}
})
app.Run(os.Args)
}