-
Notifications
You must be signed in to change notification settings - Fork 1
/
devices.go
63 lines (57 loc) · 1.17 KB
/
devices.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
package main
import (
"fmt"
"github.com/codegangsta/cli"
"github.com/modouwifi/md/api"
)
var cmdDevices = cli.Command{
Name: "devices",
Usage: "Show Devices Info",
Subcommands: []cli.Command{
{
Name: "cables",
Usage: "Show cables info",
Action: runDevicesCables,
},
{
Name: "wifis",
Usage: "Show wifis info",
Action: runDevicesWifis,
},
{
Name: "disk",
Usage: "Show disk info",
Action: runDevicesDisk,
},
},
}
func runDevicesCables(c *cli.Context) {
req, err := client.NewRequest("GET", "/devices/cables")
if err != nil {
fmt.Println(err)
}
req.SetCookie(config.Cookie)
var result api.DevicesCables
err = req.ToJSON(&result)
fmt.Println(result)
}
func runDevicesWifis(c *cli.Context) {
req, err := client.NewRequest("GET", "/devices/wifis")
if err != nil {
fmt.Println(err)
}
req.SetCookie(config.Cookie)
var result api.DevicesWifis
err = req.ToJSON(&result)
fmt.Println(result)
}
func runDevicesDisk(c *cli.Context) {
req, err := client.NewRequest("GET", "/devices/disk")
if err != nil {
fmt.Println(err)
}
req.SetCookie(config.Cookie)
var result api.DeviceDisk
err = req.ToJSON(&result)
fmt.Println(result)
}