Added export to csv

This commit is contained in:
Dmitry Lyukov
2016-03-27 02:14:30 +03:00
parent c9d59161d8
commit 77bd3bb48c

View File

@@ -241,11 +241,7 @@ func main() {
outputPath := flag.String("o", "", "Path to export file") outputPath := flag.String("o", "", "Path to export file")
flag.Parse() flag.Parse()
log.Println("keyboardId =", *keyboardId, "outputPath =", *outputPath) log.Println("keyboardId =", *keyboardId, "outputPath =", *outputPath)
switch {
case *keyboardId == -1 && *outputPath == "":
flag.PrintDefaults()
return
case *keyboardId != -1:
// Opening database // Opening database
db, err := sql.Open("sqlite3", DATABASE_NAME) db, err := sql.Open("sqlite3", DATABASE_NAME)
if err != nil { if err != nil {
@@ -257,6 +253,12 @@ func main() {
keyMap := GetKeymap() keyMap := GetKeymap()
switch {
case *keyboardId == -1 && *outputPath == "":
flag.PrintDefaults()
return
case *keyboardId != -1:
InitDb(db, keyMap) InitDb(db, keyMap)
cmd := exec.Command("xinput", "test", strconv.Itoa(*keyboardId)) cmd := exec.Command("xinput", "test", strconv.Itoa(*keyboardId))
@@ -295,6 +297,7 @@ func main() {
time.Sleep(SLEEP_TIME) time.Sleep(SLEEP_TIME)
} }
case *outputPath != "": case *outputPath != "":
//exporting here exportingData := GetStatTimesFromDb(db, 0, keyMap) //exporting here
SaveToCsvFile(exportingData, keyMap, *outputPath, false)
} }
} }