gobm65.go
changeset 24 260a31dbfda5
parent 23 7be02d3facf4
child 27 e882f78c302e
equal deleted inserted replaced
23:7be02d3facf4 24:260a31dbfda5
    64 	"os"
    64 	"os"
    65 	"sort"
    65 	"sort"
    66 	"strings"
    66 	"strings"
    67 	"time"
    67 	"time"
    68 
    68 
    69 	flag "github.com/docker/docker/pkg/mflag"
    69 	flag "github.com/spf13/pflag"
    70 	"github.com/tarm/serial"
    70 	"github.com/tarm/serial"
    71 )
    71 )
    72 
    72 
    73 type measurement struct {
    73 type measurement struct {
    74 	Header    int
    74 	Header    int
   512 			classes[c]*100/len(items))
   512 			classes[c]*100/len(items))
   513 	}
   513 	}
   514 }
   514 }
   515 
   515 
   516 func main() {
   516 func main() {
   517 	inFile := flag.String([]string{"-input-file", "i"}, "", "Input JSON file")
   517 	inFile := flag.StringP("input-file", "i", "", "Input JSON file")
   518 	outFile := flag.String([]string{"-output-file", "o"}, "", "Output JSON file")
   518 	outFile := flag.StringP("output-file", "o", "", "Output JSON file")
   519 	limit := flag.Uint([]string{"-limit", "l"}, 0, "Limit number of items to N first")
   519 	limit := flag.UintP("limit", "l", 0, "Limit number of items to N first")
   520 	toDate := flag.String([]string{"-to-date"}, "",
   520 	toDate := flag.String("to-date", "", "Filter records before date (YYYY-mm-dd HH:MM:SS)")
   521 		"Filter records before date (YYYY-mm-dd HH:MM:SS)")
   521 	fromDate := flag.String("from-date", "", "Filter records from date (YYYY-mm-dd HH:MM:SS)")
   522 	fromDate := flag.String([]string{"-from-date", "-since"}, "",
   522 	format := flag.StringP("format", "f", "", "Output format (csv, json)")
   523 		"Filter records from date (YYYY-mm-dd HH:MM:SS)")
   523 	avg := flag.BoolP("average", "a", false, "Compute average")
   524 	format := flag.String([]string{"-format", "f"}, "", "Output format (csv, json)")
   524 	stats := flag.Bool("stats", false, "Compute statistics")
   525 	avg := flag.Bool([]string{"-average", "a"}, false, "Compute average")
   525 	whoClass := flag.BoolP("class", "c", false, "Display WHO classification")
   526 	stats := flag.Bool([]string{"-stats"}, false, "Compute statistics")
   526 	merge := flag.BoolP("merge", "m", false, "Try to merge input JSON file with fetched data")
   527 	whoClass := flag.Bool([]string{"-class", "c"}, false, "Display WHO classification")
   527 	device := flag.StringP("device", "d", "/dev/ttyUSB0", "Serial device")
   528 	merge := flag.Bool([]string{"-merge", "m"}, false,
   528 	fromTime := flag.String("from-time", "", "Select records after time (HH:MM)")
   529 		"Try to merge input JSON file with fetched data")
   529 	toTime := flag.String("to-time", "", "Select records bofore time (HH:MM)")
   530 	device := flag.String([]string{"-device", "d"}, "/dev/ttyUSB0", "Serial device")
   530 
   531 	fromTime := flag.String([]string{"-from-time"}, "", "Select records after time (HH:MM)")
   531 	flag.StringVar(fromDate, "since", "", "Same as --from-date")
   532 	toTime := flag.String([]string{"-to-time"}, "", "Select records bofore time (HH:MM)")
       
   533 
   532 
   534 	var startTime, endTime simpleTime
   533 	var startTime, endTime simpleTime
   535 
   534 
   536 	flag.Parse()
   535 	flag.Parse()
   537 
   536