forked from bpicode/fritzctl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
boxinfo.go
36 lines (30 loc) · 894 Bytes
/
boxinfo.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
package cmd
import (
"fmt"
"github.com/bpicode/fritzctl/console"
"github.com/bpicode/fritzctl/fritz"
"github.com/spf13/cobra"
)
var boxInfoCmd = &cobra.Command{
Use: "boxinfo",
Short: "Display information about the FRITZ!Box",
Long: "Show information about the FRITZ!Box like firmware version, uptime, etc.",
Example: "fritzctl boxinfo",
RunE: boxInfo,
}
func init() {
RootCmd.AddCommand(boxInfoCmd)
}
func boxInfo(_ *cobra.Command, _ []string) error {
c := clientLogin()
f := fritz.NewInternal(c)
info, err := f.BoxInfo()
assertNoErr(err, "cannot obtain FRITZ!Box data")
printBoxInfo(info)
return nil
}
func printBoxInfo(boxData *fritz.BoxData) {
fmt.Printf("%s %s\n", console.Cyan("Model: "), boxData.Model)
fmt.Printf("%s %s\n", console.Cyan("Firmware: "), boxData.FirmwareVersion)
fmt.Printf("%s %s\n", console.Cyan("Running: "), boxData.Runtime)
}