abstract terminal interface
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package drivers
|
||||
|
||||
import (
|
||||
"finally-a-monolithic-linux-hw-monitor/app/common"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -28,18 +29,18 @@ func NewRaplDriver() (*RaplDriver, error) {
|
||||
return &r, err
|
||||
}
|
||||
|
||||
func (r *RaplDriver) Render(console *strings.Builder) error {
|
||||
fmt.Fprint(console, "--- Power ---\033[K\n")
|
||||
func (r *RaplDriver) Render(term common.Terminal) error {
|
||||
p, err := r.Read()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
power := p.([]PowerSensor)
|
||||
term.Subheader("Power")
|
||||
|
||||
for _, sensor := range power {
|
||||
// \033[K clears from cursor to end of line (prevents lingering chars)
|
||||
fmt.Fprintf(console, "%-16s | %.2f W\033[K\n", sensor.Name, sensor.Watts)
|
||||
term.Print(fmt.Sprintf("%-16s | %.2f W", sensor.Name, sensor.Watts))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user