mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
SystemInfo struct is now master of its own domain
This commit is contained in:
parent
0ff65bbd5c
commit
89497561bc
@ -1,7 +1,10 @@
|
|||||||
package system
|
package system
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SystemInfo struct {
|
type SystemInfo struct {
|
||||||
@ -10,9 +13,14 @@ type SystemInfo struct {
|
|||||||
BuildVersion string
|
BuildVersion string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSystemInfo(raw string) *SystemInfo {
|
func NewSystemInfo() *SystemInfo {
|
||||||
m := make(map[string]string)
|
m := make(map[string]string)
|
||||||
|
|
||||||
|
arg := []string{}
|
||||||
|
|
||||||
|
cmd := exec.Command("sw_vers", arg...)
|
||||||
|
raw := wtf.ExecuteCommand(cmd)
|
||||||
|
|
||||||
for _, row := range strings.Split(raw, "\n") {
|
for _, row := range strings.Split(raw, "\n") {
|
||||||
parts := strings.Split(row, ":")
|
parts := strings.Split(row, ":")
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package system
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
@ -28,7 +27,7 @@ func NewWidget(builtAt, version string) *Widget {
|
|||||||
Version: version,
|
Version: version,
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.buildSystemInfo()
|
widget.systemInfo = NewSystemInfo()
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
@ -64,12 +63,3 @@ func (widget *Widget) prettyBuiltAt() string {
|
|||||||
return str.Format("Jan _2, 15:04")
|
return str.Format("Jan _2, 15:04")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) buildSystemInfo() {
|
|
||||||
arg := []string{}
|
|
||||||
|
|
||||||
cmd := exec.Command("sw_vers", arg...)
|
|
||||||
str := wtf.ExecuteCommand(cmd)
|
|
||||||
|
|
||||||
widget.systemInfo = NewSystemInfo(str)
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user