add: termperatures log

This commit is contained in:
2018-11-30 21:50:43 +01:00
parent 7b18b115c8
commit ba9f0c59f3
5 changed files with 135 additions and 39 deletions

26
cmd/temperature/log.go Normal file
View File

@ -0,0 +1,26 @@
package temperature
import (
"log"
"os"
"git.cryptic.systems/fh-trier/go-flucky/pkg/logs"
"github.com/spf13/cobra"
)
var writeLog bool
var logTemperatureCmd = &cobra.Command{
Use: "log",
Short: "Log print all temperatures saved from logfile on stdout",
Run: func(cmd *cobra.Command, args []string) {
if err := logs.ListTemperatures(configDir, os.Stdout); err != nil {
log.Fatal(err)
}
},
}
func init() {
temperatureCmd.AddCommand(logTemperatureCmd)
}

View File

@ -1,23 +0,0 @@
package temperature
import (
"github.com/spf13/cobra"
)
var writeLog bool
var printTemperatureCmd = &cobra.Command{
Use: "print",
Short: "print all temperatures from all sensors secondly",
Run: func(cmd *cobra.Command, args []string) {
// if err := temperature.Print(os.Stdout, configDir, writeLog); err != nil {
// log.Fatal(err)
// }
},
}
func init() {
temperatureCmd.AddCommand(printTemperatureCmd)
printTemperatureCmd.Flags().BoolVarP(&writeLog, "log", "l", true, "Append to logfiles")
}