terrible smart driver
This commit is contained in:
+15
-15
@@ -8,24 +8,17 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (proc *Proc) Render(term common.Terminal) {
|
||||
term.Header(proc.Model())
|
||||
for _, driver := range proc.drivers {
|
||||
driver.Render(term)
|
||||
}
|
||||
}
|
||||
|
||||
type Proc struct {
|
||||
drivers []common.Driver
|
||||
Info map[string]string
|
||||
}
|
||||
|
||||
const (
|
||||
VendorIntel string = "GenuineIntel"
|
||||
VendorAMD string = "AuthenticAMD"
|
||||
VendorUnknown string = "Unknown"
|
||||
)
|
||||
|
||||
type Proc struct {
|
||||
drivers []common.Driver
|
||||
Info map[string]string
|
||||
}
|
||||
|
||||
func GetProc() (Proc, error) {
|
||||
// open and parse cpuinfo
|
||||
proc := Proc{}
|
||||
@@ -56,7 +49,7 @@ func GetProc() (Proc, error) {
|
||||
}
|
||||
}
|
||||
|
||||
vendor := proc.Vendor()
|
||||
vendor := proc.vendor()
|
||||
|
||||
switch vendor {
|
||||
case VendorIntel:
|
||||
@@ -72,10 +65,17 @@ func GetProc() (Proc, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (proc *Proc) Vendor() string {
|
||||
func (proc *Proc) Render(term common.Terminal) {
|
||||
term.Header(proc.model())
|
||||
for _, driver := range proc.drivers {
|
||||
driver.Render(term)
|
||||
}
|
||||
}
|
||||
|
||||
func (proc *Proc) vendor() string {
|
||||
return proc.Info["vendor_id"]
|
||||
}
|
||||
|
||||
func (proc *Proc) Model() string {
|
||||
func (proc *Proc) model() string {
|
||||
return proc.Info["model name"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user