forked from juruen/rmapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (36 loc) · 757 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
39
40
41
42
43
44
45
46
package main
import (
"flag"
"os"
"github.com/juruen/rmapi/api"
"github.com/juruen/rmapi/log"
"github.com/juruen/rmapi/shell"
)
const AUTH_RETRIES = 3
func run_shell(ctx *api.ApiCtx, args []string) {
err := shell.RunShell(ctx, args)
if err != nil {
log.Error.Println("Error: ", err)
os.Exit(1)
}
}
func main() {
log.InitLog()
ni := flag.Bool("ni", false, "not interactive")
flag.Parse()
rstArgs := flag.Args()
var ctx *api.ApiCtx
var err error
for i := 0; i < AUTH_RETRIES; i++ {
ctx, err = api.CreateApiCtx(api.AuthHttpCtx(i > 0, *ni))
if err != nil {
log.Trace.Println(err)
} else {
break
}
}
if ctx == nil {
log.Error.Fatal("failed to build documents tree, last error: ", err)
}
run_shell(ctx, rstArgs)
}