feat(cmd/temperature/compress): new subcommand to compress logfiles
This commit is contained in:
35
cmd/temperature/compression.go
Normal file
35
cmd/temperature/compression.go
Normal file
@ -0,0 +1,35 @@
|
||||
package temperature
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/go-flucky/flucky/pkg/logfile"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var compressTemperatureCmd = &cobra.Command{
|
||||
Use: "compress",
|
||||
Short: "Compress temperature logfiles",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Example: `flucky temperature compress /var/log/flucky/temperature.json
|
||||
flucky temperature compress /var/log/flucky/temperature.xml`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
temperatureLogfile := logfile.New(args[0])
|
||||
temperatures, err := temperatureLogfile.ReadTemperatures()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
temperatures = logfile.CompressTemperature(temperatures)
|
||||
|
||||
err = temperatureLogfile.WriteTemperatures(temperatures)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
temperatureCmd.AddCommand(compressTemperatureCmd)
|
||||
}
|
@ -7,9 +7,6 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var logfileInput string
|
||||
var logfileOutput string
|
||||
|
||||
var convertTemperatureCmd = &cobra.Command{
|
||||
Use: "convert",
|
||||
Short: "Convert temperature logfiles into other markup language",
|
||||
|
Reference in New Issue
Block a user