mirror of
https://github.com/jwetzell/osc-go.git
synced 2026-09-01 19:49:02 +00:00
switch makeosc to urfave/cli
This commit is contained in:
+36
-10
@@ -1,13 +1,14 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
osc "github.com/jwetzell/osc-go"
|
osc "github.com/jwetzell/osc-go"
|
||||||
"github.com/spf13/cobra"
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -16,18 +17,43 @@ func main() {
|
|||||||
var Types []string
|
var Types []string
|
||||||
var Slip bool
|
var Slip bool
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
cmd := &cli.Command{
|
||||||
Use: "makeosc",
|
Name: "makeosc",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Usage: "make osc bytes",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "address",
|
||||||
|
Value: "",
|
||||||
|
Usage: "OSC address",
|
||||||
|
Destination: &Address,
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
&cli.StringSliceFlag{
|
||||||
|
Name: "arg",
|
||||||
|
Usage: "OSC args",
|
||||||
|
Destination: &Args,
|
||||||
|
},
|
||||||
|
&cli.StringSliceFlag{
|
||||||
|
Name: "type",
|
||||||
|
Usage: "OSC types",
|
||||||
|
Destination: &Types,
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "slip",
|
||||||
|
Value: false,
|
||||||
|
Usage: "whether to slip encode the OSC Message bytes",
|
||||||
|
Destination: &Slip,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||||
make(Address, Args, Types, Slip)
|
make(Address, Args, Types, Slip)
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
rootCmd.Flags().StringVar(&Address, "address", "", "OSC address")
|
|
||||||
rootCmd.Flags().StringArrayVar(&Args, "arg", []string{}, "OSC args")
|
if err := cmd.Run(context.Background(), os.Args); err != nil {
|
||||||
rootCmd.Flags().StringArrayVar(&Types, "type", []string{}, "OSC types")
|
panic(err)
|
||||||
rootCmd.Flags().BoolVar(&Slip, "slip", false, "whether to slip encode the OSC Message bytes")
|
}
|
||||||
rootCmd.MarkFlagRequired("address")
|
|
||||||
rootCmd.Execute()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func argToTypedArg(rawArg string, oscType string) osc.OSCArg {
|
func argToTypedArg(rawArg string, oscType string) osc.OSCArg {
|
||||||
|
|||||||
Reference in New Issue
Block a user