forked from untoldone/bloomapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbloomapi.go
48 lines (42 loc) · 906 Bytes
/
bloomapi.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
package main
import (
"os"
"fmt"
"github.com/spf13/viper"
"github.com/untoldone/bloomapi/cmd"
)
func showUsage() {
fmt.Println("Usage: bloomapi <command>")
fmt.Println("=============================\n")
fmt.Println("Avaialable commands:")
fmt.Println("bloomapi server # run BloomAPI server")
fmt.Println("bloomapi bootstrap # setup BloomAPI shared schema")
fmt.Println("bloomapi drop # remove all BloomAPI shared tables")
}
func main() {
if (len(os.Args) != 2) {
fmt.Println("Invalid command usage\n")
showUsage()
os.Exit(1)
}
arg := os.Args[1]
viper.SetConfigName("config")
viper.AddConfigPath("./")
err := viper.ReadInConfig()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
switch arg {
case "server":
cmd.Server()
case "bootstrap":
cmd.Bootstrap()
case "drop":
cmd.Drop()
default:
fmt.Println("Invalid command:", arg)
showUsage()
os.Exit(1)
}
}