raw doesn't need to be a command group

fix `nil pointer deference` for set commands
This commit is contained in:
onyx-and-iris 2026-02-05 04:01:34 +00:00
parent 8539685770
commit 139e092937
2 changed files with 6 additions and 8 deletions

View File

@ -44,7 +44,7 @@ type CLI struct {
Completion kongcompletion.Completion `help:"Generate shell completion scripts." cmd:"" aliases:"c"` 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"` Main MainCmdGroup `help:"Control the Main L/R output" cmd:"" group:"Main"`
Strip StripCmdGroup `help:"Control the strips." cmd:"" group:"Strip"` Strip StripCmdGroup `help:"Control the strips." cmd:"" group:"Strip"`
Bus BusCmdGroup `help:"Control the buses." cmd:"" group:"Bus"` Bus BusCmdGroup `help:"Control the buses." cmd:"" group:"Bus"`

12
raw.go
View File

@ -5,17 +5,13 @@ import (
"time" "time"
) )
type RawCmdGroup struct { type RawCmd struct {
Send RawSendCmd `help:"Send a raw OSC message to the mixer." cmd:""`
}
type RawSendCmd struct {
Timeout time.Duration `help:"Timeout for the OSC message send operation." default:"200ms" short:"t"` 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:""` 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:""` 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)) params := make([]any, len(cmd.Args))
for i, arg := range cmd.Args { for i, arg := range cmd.Args {
params[i] = arg params[i] = arg
@ -28,7 +24,9 @@ func (cmd *RawSendCmd) Run(ctx *context) error {
if err != nil { if err != nil {
return fmt.Errorf("failed to receive response for raw OSC message: %w", err) 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 return nil
} }