// @osc: the OSC client package main import ( "log" "os" "strconv" "github.com/hypebeast/go-osc/osc" ) func main() { // Check if we have all the required argumets to send the OSC message if len(os.Args) < 2 { log.New(os.Stderr, "", 0).Fatal("Usage: ", os.Args[0], " /osc/address [message...]") } host := os.Getenv("athost") if host == "" { host = "localhost" } atport := os.Getenv("atport") port, err := strconv.Atoi(atport) if err != nil { port = 9137 } client := osc.NewClient(host, port) msg := osc.NewMessage(os.Args[1]) have_string := false have_blob := false for _, arg := range os.Args[2:] { if have_string { msg.Append(arg) have_string = false } else if arg == "-s" { have_string = true } else if have_blob { content, err := os.ReadFile(arg) if err != nil { log.Print(err) } msg.Append(content) have_blob = false } else if arg == "-b" { have_blob = true } else if arg == "true" { msg.Append(true) } else if arg == "false" { msg.Append(false) } else if i, err := strconv.Atoi(arg); err == nil { msg.Append(int32(i)) } else if f, err := strconv.ParseFloat(arg, 64); err == nil { msg.Append(float32(f)) } else { msg.Append(arg) } } if err := client.Send(msg); err != nil { log.Fatal(err) } }