fix: moved print functions into cli pkg
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
||||
"git.cryptic.systems/fh-trier/go-flucky/pkg/types"
|
||||
)
|
||||
|
||||
// PrintHumidities displays a list of humidities
|
||||
func PrintHumidities(humidities []*types.Humidity, cnf *config.FluckyConfig, w io.Writer) {
|
||||
// determine all humidity sensors based on the humidiy values
|
||||
sensors := []*types.Sensor{}
|
||||
@ -66,6 +67,40 @@ func PrintHumidities(humidities []*types.Humidity, cnf *config.FluckyConfig, w i
|
||||
tw.Flush()
|
||||
}
|
||||
|
||||
// PrintRemotes displays a list with all configured remote addresses
|
||||
func PrintRemotes(cnf *config.FluckyConfig, w io.Writer) error {
|
||||
|
||||
tw := tabwriter.NewWriter(w, 0, 0, 3, ' ', 0)
|
||||
|
||||
fmt.Fprint(tw, "name\taddress\tenabled\tregistered\n")
|
||||
|
||||
for _, remote := range cnf.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 PrintSensors(cnf *config.FluckyConfig, 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 cnf.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
|
||||
}
|
||||
|
||||
// PrintTemperatures displays a list of temperatures
|
||||
func PrintTemperatures(temperatures []*types.Temperature, cnf *config.FluckyConfig, w io.Writer) {
|
||||
|
||||
sensors := []*types.Sensor{}
|
||||
|
Reference in New Issue
Block a user