-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
64 lines (54 loc) · 1 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
package main
import (
"fmt"
"os"
"path/filepath"
"runtime"
"github.com/codegangsta/cli"
)
const VERSION = "0.0.0"
var (
client *Client
config *Config
apiURL = "http://modouwifi.net/api"
mdAgent = "md/" + VERSION + " (" + runtime.GOOS + "; " + runtime.GOARCH + ")"
app = cli.NewApp()
)
func initClient() {
client = NewClient(apiURL, mdAgent)
config = &Config{}
file, err := LocateRcfile()
if err != nil {
err = os.MkdirAll(filepath.Dir(file), os.ModePerm)
if err != nil {
fmt.Println(err.Error())
}
_, err := os.OpenFile(file, os.O_CREATE, os.ModePerm)
if err != nil {
fmt.Println(err.Error())
}
}
config.Filename = file
config.Read()
}
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
app.Name = "md"
app.Usage = "Command Line Utility for Modou"
app.Version = VERSION
app.Commands = append(app.Commands,
cmdLogin,
cmdLogout,
cmdSystem,
cmdSecurity,
cmdWan,
cmdWifi,
cmdLan,
cmdDevices,
cmdApps,
)
}
func main() {
initClient()
app.Run(os.Args)
}