diff --git a/cmd/x32-cli/cli.go b/cmd/x32-cli/cli.go index ef7ab09..59eaa46 100644 --- a/cmd/x32-cli/cli.go +++ b/cmd/x32-cli/cli.go @@ -46,9 +46,10 @@ type CLI struct { Version VersionFlag `help:"Print x32-cli version information and quit" name:"version" short:"v"` - Completion kongcompletion.Completion `help:"Generate shell completion scripts." cmd:"" aliases:"c"` + Completion kongcompletion.Completion `help:"Generate shell completion scripts." cmd:""` + Info InfoCmd `help:"Print mixer information." cmd:""` + Raw RawCmd `help:"Send raw OSC messages to the mixer." cmd:""` - 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"` Mainmono MainMonoCmdGroup `help:"Control the Main Mono output" cmd:"" group:"MainMono"` Matrix MatrixCmdGroup `help:"Control the matrix outputs." cmd:"" group:"Matrix"` diff --git a/cmd/x32-cli/info.go b/cmd/x32-cli/info.go new file mode 100644 index 0000000..43472a0 --- /dev/null +++ b/cmd/x32-cli/info.go @@ -0,0 +1,18 @@ +package main + +import "fmt" + +type InfoCmd struct { +} + +func (c *InfoCmd) Run(ctx *context) error { + fmt.Fprintf( + ctx.Out, + "Host: %s | Name: %s | Model: %s | Firmware: %s\n", + ctx.Client.Info.Host, + ctx.Client.Info.Name, + ctx.Client.Info.Model, + ctx.Client.Info.Firmware, + ) + return nil +} diff --git a/cmd/xair-cli/cli.go b/cmd/xair-cli/cli.go index aa7aacb..d33e5a1 100644 --- a/cmd/xair-cli/cli.go +++ b/cmd/xair-cli/cli.go @@ -46,9 +46,10 @@ type CLI struct { Version VersionFlag `help:"Print xair-cli version information and quit" name:"version" short:"v"` - Completion kongcompletion.Completion `help:"Generate shell completion scripts." cmd:"" aliases:"c"` + Completion kongcompletion.Completion `help:"Generate shell completion scripts." cmd:""` + Info InfoCmd `help:"Print mixer information." cmd:""` + Raw RawCmd `help:"Send raw OSC messages to the mixer." cmd:""` - 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"` diff --git a/cmd/xair-cli/info.go b/cmd/xair-cli/info.go new file mode 100644 index 0000000..43472a0 --- /dev/null +++ b/cmd/xair-cli/info.go @@ -0,0 +1,18 @@ +package main + +import "fmt" + +type InfoCmd struct { +} + +func (c *InfoCmd) Run(ctx *context) error { + fmt.Fprintf( + ctx.Out, + "Host: %s | Name: %s | Model: %s | Firmware: %s\n", + ctx.Client.Info.Host, + ctx.Client.Info.Name, + ctx.Client.Info.Model, + ctx.Client.Info.Firmware, + ) + return nil +} diff --git a/internal/xair/client.go b/internal/xair/client.go index 488f401..b1f34e0 100644 --- a/internal/xair/client.go +++ b/internal/xair/client.go @@ -28,7 +28,7 @@ func NewXAirClient(mixerIP string, mixerPort int, opts ...EngineOption) (*XAirCl } c := &XAirClient{ - client: client{e}, + client: client{e, InfoResponse{}}, } c.Main = newMainStereo(&c.client) c.Strip = newStrip(&c.client) @@ -61,7 +61,7 @@ func NewX32Client(mixerIP string, mixerPort int, opts ...EngineOption) (*X32Clie } c := &X32Client{ - client: client{e}, + client: client{e, InfoResponse{}}, } c.Main = newMainStereo(&c.client) c.MainMono = newMainMono(&c.client) @@ -77,6 +77,7 @@ func NewX32Client(mixerIP string, mixerPort int, opts ...EngineOption) (*X32Clie type client struct { *engine + Info InfoResponse } // Start begins listening for messages in a goroutine @@ -124,11 +125,22 @@ func (c *client) RequestInfo() (InfoResponse, error) { if err != nil { return info, err } - if len(msg.Arguments) >= 3 { - info.Host = msg.Arguments[0].(string) - info.Name = msg.Arguments[1].(string) - info.Model = msg.Arguments[2].(string) + if len(msg.Arguments) == 4 { + if host, ok := msg.Arguments[0].(string); ok { + info.Host = host + } + if name, ok := msg.Arguments[1].(string); ok { + info.Name = name + } + if model, ok := msg.Arguments[2].(string); ok { + info.Model = model + } + if firmware, ok := msg.Arguments[3].(string); ok { + info.Firmware = firmware + } } + c.Info = info + return info, nil } diff --git a/internal/xair/models.go b/internal/xair/models.go index 0e94c3d..75a6ee6 100644 --- a/internal/xair/models.go +++ b/internal/xair/models.go @@ -1,7 +1,8 @@ package xair type InfoResponse struct { - Host string - Name string - Model string + Host string + Name string + Model string + Firmware string } diff --git a/x32-help.md b/x32-help.md index de8e735..767979e 100644 --- a/x32-help.md +++ b/x32-help.md @@ -12,10 +12,9 @@ Flags: -v, --version Print x32-cli version information and quit Commands: - completion (c) Generate shell completion scripts. - -Raw - raw Send raw OSC messages to the mixer. + completion Generate shell completion scripts. + info Print mixer information. + raw Send raw OSC messages to the mixer. Main main mute Get or set the mute state of the Main L/R output. diff --git a/xair-help.md b/xair-help.md index 1fbad4f..b3e85cf 100644 --- a/xair-help.md +++ b/xair-help.md @@ -12,10 +12,9 @@ Flags: -v, --version Print xair-cli version information and quit Commands: - completion (c) Generate shell completion scripts. - -Raw - raw Send raw OSC messages to the mixer. + completion Generate shell completion scripts. + info Print mixer information. + raw Send raw OSC messages to the mixer. Main main mute Get or set the mute state of the Main L/R output.