fix: moved print functions into cli pkg

This commit is contained in:
2019-03-04 11:31:01 +01:00
parent 4bae510120
commit a243021c70
4 changed files with 39 additions and 36 deletions

View File

@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"text/tabwriter"
"time"
"git.cryptic.systems/fh-trier/go-flucky/pkg/logger"
@ -302,39 +301,6 @@ func (fc *FluckyConfig) JSONWriter(w io.Writer) error {
return nil
}
// PrintRemotes displays a list with all configured remote addresses
func (fc *FluckyConfig) PrintRemotes(w io.Writer) error {
tw := tabwriter.NewWriter(w, 0, 0, 3, ' ', 0)
fmt.Fprint(tw, "name\taddress\tenabled\tregistered\n")
for _, remote := range fc.Remotes {
fmt.Fprintf(tw, "%v\t%v\t%v\t%v\n", remote.Name, remote.Address, remote.Enabled, remote.Registered)
}
tw.Flush()
return nil
}
// PrintSensors displays a list with all configured sensors
func (fc *FluckyConfig) PrintSensors(w io.Writer) error {
// declar tabwriter
tw := tabwriter.NewWriter(w, 0, 0, 3, ' ', 0)
fmt.Fprint(tw, "name\tlocation\ttype\twire-id\tgpio\tenabled\n")
for _, sensor := range fc.Sensors {
fmt.Fprintf(tw, "%v\t%v\t%v\t%v\t%v\t%v\n", sensor.SensorName, sensor.SensorLocation, sensor.SensorModel, *sensor.WireID, *sensor.GPIONumber, sensor.SensorEnabled)
}
tw.Flush()
return nil
}
// RemoveSensor deletes a sensor by its name or its unique UUID
func (fc *FluckyConfig) RemoveSensor(nameOrUUID string) error {
for i, sensor := range fc.Sensors {