package convert import ( "log" "github.com/Masterminds/semver" "github.com/go-flucky/flucky/pkg/logfile" "github.com/spf13/cobra" ) var ( compression bool configFile *string version *semver.Version ) var convertCmd = &cobra.Command{ Use: "convert", Short: "Convert logfiles into other markup language", Args: cobra.ExactArgs(2), Example: "flucky convert /var/log/flucky/logfile.json /var/log/flucky/logfile.csv", Run: func(cmd *cobra.Command, args []string) { measuredValuesInput := logfile.New(args[0]) measuredValues, err := measuredValuesInput.Read() if err != nil { log.Fatalln(err) } if compression { measuredValues = logfile.Compression(measuredValues) } measuredValuesOutput := logfile.New(args[1]) err = measuredValuesOutput.Write(measuredValues) if err != nil { log.Fatalln(err) } }, } // Execute a func InitCmd(cmd *cobra.Command, cnfFile *string, sversion *semver.Version) { configFile = cnfFile version = sversion cmd.AddCommand(convertCmd) convertCmd.Flags().BoolVar(&compression, "compression", true, "Compress measured values") }