diff --git a/cmd/temperature/convert.go b/cmd/temperature/convert.go new file mode 100644 index 0000000..13f4177 --- /dev/null +++ b/cmd/temperature/convert.go @@ -0,0 +1,38 @@ +package temperature + +import ( + "log" + + "github.com/go-flucky/flucky/pkg/logfile" + "github.com/spf13/cobra" +) + +var logfileInput string +var logfileOutput string + +var convertTemperatureCmd = &cobra.Command{ + Use: "convert", + Short: "Convert temperature logfiles into other markup language", + Args: cobra.ExactArgs(2), + Example: "flucky temperature convert /var/log/flucky/temperature.json /var/log/flucky/temperature.xml", + Run: func(cmd *cobra.Command, args []string) { + + temperatureLogfileInput := logfile.New(args[0]) + temperatures, err := temperatureLogfileInput.ReadTemperatures() + if err != nil { + log.Fatalln(err) + } + + temperatureLogfileOutput := logfile.New(args[1]) + err = temperatureLogfileOutput.WriteTemperatures(temperatures) + if err != nil { + log.Fatalln(err) + } + }, +} + +func init() { + temperatureCmd.AddCommand(convertTemperatureCmd) + convertTemperatureCmd.Flags().BoolVar(&compression, "compression", true, "Compress measured values") + convertTemperatureCmd.Flags().Float64Var(&round, "round", 0.25, "Round values. The value 0 deactivates the function") +} diff --git a/cmd/temperature/read.go b/cmd/temperature/read.go index 20d347e..dc95719 100644 --- a/cmd/temperature/read.go +++ b/cmd/temperature/read.go @@ -12,9 +12,7 @@ import ( "github.com/spf13/cobra" ) -var compression bool var logs bool -var round float64 var readTemperatureCmd = &cobra.Command{ Use: "read", diff --git a/cmd/temperature/temperature.go b/cmd/temperature/temperature.go index 6be121a..3703ce8 100644 --- a/cmd/temperature/temperature.go +++ b/cmd/temperature/temperature.go @@ -6,7 +6,9 @@ import ( "github.com/spf13/cobra" ) +var compression bool var configFile string +var round float64 var temperatureCmd = &cobra.Command{ Use: "temperature",