Added parsing arguments of command line

This commit is contained in:
Dmitry Lyukov
2016-03-26 16:32:57 +03:00
parent 4b990bcc82
commit e6fa93c856

View File

@@ -2,6 +2,7 @@
package main package main
import ( import (
"flag"
"fmt" "fmt"
"log" "log"
"os/exec" "os/exec"
@@ -67,8 +68,16 @@ func GetKeyNumsFromOutput(buf []byte) []uint8 {
func main() { func main() {
keyboardID := 14 keyboardId := flag.Int("id", -1, "Your keyboard id")
cmd := exec.Command("xinput", "test", strconv.Itoa(keyboardID)) outputPath := flag.String("o", "", "Path to export file")
flag.Parse()
log.Println("keyboardId =", *keyboardId, "outputPath =", *outputPath)
switch {
case *keyboardId == -1 && *outputPath == "":
flag.PrintDefaults()
return
case *keyboardId != -1:
cmd := exec.Command("xinput", "test", strconv.Itoa(*keyboardId))
stdout, err := cmd.StdoutPipe() stdout, err := cmd.StdoutPipe()
if err != nil { if err != nil {
@@ -88,4 +97,7 @@ func main() {
fmt.Println(n) fmt.Println(n)
time.Sleep(SLEEP_TIME) time.Sleep(SLEEP_TIME)
} }
case *outputPath != "":
//exporting here
}
} }