-
Notifications
You must be signed in to change notification settings - Fork 646
/
status.go
45 lines (38 loc) 路 797 Bytes
/
status.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
package status
import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"log"
"wgcf/cloudflare/api"
. "wgcf/cmd/util"
"wgcf/util"
)
var shortMsg = "Prints the status of the current Cloudflare Warp device"
var Cmd = &cobra.Command{
Use: "status",
Short: shortMsg,
Long: FormatMessage(shortMsg, ""),
Run: func(cmd *cobra.Command, args []string) {
if err := status(); err != nil {
log.Fatal(util.GetErrorMessage(err))
}
},
}
func init() {
}
func status() error {
if !ValidAccount() {
return errors.New("no valid account detected")
}
ctx := CreateContext()
deviceData, err := api.GetDeviceData(ctx)
if err != nil {
return err
}
boundDevice, err := api.GetBoundDevice(ctx)
if err != nil {
return err
}
PrintDeviceData(deviceData, boundDevice)
return nil
}