-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.go
48 lines (40 loc) · 1.06 KB
/
commands.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 (
"fmt"
"os"
"os/exec"
"github.com/stockholmr/fogcli/fog"
"github.com/stockholmr/fogcli/repl"
)
func RegisterCommands() {
repl.AddCommand(&repl.Command{
Name: "clear",
Description: "clear console window",
Cmd: func(params map[string]string) {
cmd := exec.Command("clear")
cmd.Stdout = os.Stdout
cmd.Run()
},
}) // end clear
repl.AddCommand(&repl.Command{
Name: "connect",
Description: "Connect to fogserver database",
Params: []string{"server", "username", "password", "database"},
Cmd: func(params map[string]string) {
fog.Connect(params["server"], params["username"], params["password"], params["database"])
},
}) // end connect
hostGroup := repl.NewCommandGroup("host", "", "")
hostGroup.AddCommand(&repl.Command{
Name: "list",
Description: "List Hosts",
Cmd: func(params map[string]string) {
hosts, err := fog.Hosts_List()
if err != nil {
fmt.Println(err.Error())
}
fmt.Print(hosts)
},
}) // end hosts.list
repl.AddGroup(hostGroup)
} // end RegisterCommands