forked from danielgtaylor/restish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (29 loc) · 963 Bytes
/
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
package main
import (
"os"
"github.com/danielgtaylor/restish/cli"
"github.com/danielgtaylor/restish/oauth"
"github.com/danielgtaylor/restish/openapi"
)
var version string = "dev"
var commit string
var date string
func main() {
if version == "dev" {
// Try to add the executable modification time to the dev version.
filename, _ := os.Executable()
if info, err := os.Stat(filename); err == nil {
version += "-" + info.ModTime().Format("2006-01-02-15:04")
}
}
cli.Init("restish", version)
// Register default encodings, content type handlers, and link parsers.
cli.Defaults()
// Register format loaders to auto-discover API descriptions
cli.AddLoader(openapi.New())
// Register auth schemes
cli.AddAuth("oauth-client-credentials", &oauth.ClientCredentialsHandler{})
cli.AddAuth("oauth-authorization-code", &oauth.AuthorizationCodeHandler{})
// Run the CLI, parsing arguments, making requests, and printing responses.
cli.Run()
}