mirror of
https://github.com/onyx-and-iris/xair-cli.git
synced 2026-02-26 08:19:11 +00:00
raw doesn't need to be a command group
fix `nil pointer deference` for set commands
This commit is contained in:
parent
8539685770
commit
139e092937
2
main.go
2
main.go
@ -44,7 +44,7 @@ type CLI struct {
|
||||
|
||||
Completion kongcompletion.Completion `help:"Generate shell completion scripts." cmd:"" aliases:"c"`
|
||||
|
||||
Raw RawCmdGroup `help:"Send raw OSC messages to the mixer." cmd:"" group:"Raw"`
|
||||
Raw RawCmd `help:"Send raw OSC messages to the mixer." cmd:"" group:"Raw"`
|
||||
Main MainCmdGroup `help:"Control the Main L/R output" cmd:"" group:"Main"`
|
||||
Strip StripCmdGroup `help:"Control the strips." cmd:"" group:"Strip"`
|
||||
Bus BusCmdGroup `help:"Control the buses." cmd:"" group:"Bus"`
|
||||
|
||||
12
raw.go
12
raw.go
@ -5,17 +5,13 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type RawCmdGroup struct {
|
||||
Send RawSendCmd `help:"Send a raw OSC message to the mixer." cmd:""`
|
||||
}
|
||||
|
||||
type RawSendCmd struct {
|
||||
type RawCmd struct {
|
||||
Timeout time.Duration `help:"Timeout for the OSC message send operation." default:"200ms" short:"t"`
|
||||
Address string `help:"The OSC address to send the message to." arg:""`
|
||||
Args []string `help:"The arguments to include in the OSC message." arg:"" optional:""`
|
||||
}
|
||||
|
||||
func (cmd *RawSendCmd) Run(ctx *context) error {
|
||||
func (cmd *RawCmd) Run(ctx *context) error {
|
||||
params := make([]any, len(cmd.Args))
|
||||
for i, arg := range cmd.Args {
|
||||
params[i] = arg
|
||||
@ -28,7 +24,9 @@ func (cmd *RawSendCmd) Run(ctx *context) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to receive response for raw OSC message: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Received response: %s with args: %v\n", msg.Address, msg.Arguments)
|
||||
if msg != nil {
|
||||
fmt.Fprintf(ctx.Out, "Received response: %s with args: %v\n", msg.Address, msg.Arguments)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user