-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
91 lines (73 loc) · 1.95 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main
import (
// "log"
// "os"
"fmt"
"flag"
// "encoding/json"
// "io/ioutil"
"github.com/minimalchat/chatctl/commands"
"github.com/minimalchat/mnml-daemon/operator"
)
type configuration struct {
ConfigFile string
Host string
}
type chatrc struct {
operator operator.Operator
}
var config configuration
// var commands map[int]string
func help() {
fmt.Println("chatctl controls the Chat daemon\n")
fmt.Println("Find more information at https://github.com/letschat/chatctl\n")
fmt.Println("Usage:")
fmt.Println("\tchatctl [flags] COMMAND")
fmt.Println("\tchatctl COMMAND\n")
fmt.Println("Commands:")
fmt.Println(" get\tDisplay one or many resources")
fmt.Println(" config\tModifies config files")
fmt.Println("")
fmt.Println("Flags:")
flag.PrintDefaults()
}
func init() {
// Configuration
flag.StringVar(&config.Host, "api-server", "http://localhost:8000", "The `address` of the API server")
flag.StringVar(&config.ConfigFile, "config", "~/.chatrc", "Path to chat config `file`, specifying operator and how to authenticate to the API server")
}
func main() {
flag.Parse()
argv := flag.Args()
// // Try to load config file
// if config.ConfigFile != "" {
// // Open file
// // log.Println(fmt.Sprintf("Opening %s ...", config.ConfigFile))
// confData, _ = ioutil.ReadFile(config.ConfigFile)
// // if err != nil {
// // panic(err)
// // }
// } else {
// // Open file
// // log.Println("Opening ~/.chatrc ...")
// confData, _ = ioutil.ReadFile("~/.chatrc")
// // if err != nil {
// // panic(err)
// // }
// }
// // fmt.Println(string(confData))
// err := json.Unmarshal(confData, &confObject)
// if err != nil {
// log.Fatal(err)
// }
if len(argv) > 0 {
fmt.Println(argv[0])
switch {
case argv[0] == "get": cmds.Get(argv)
// case argv[0] == "config": cmds.Config(argv)
default: help()
}
} else {
help()
}
}