implement info command

upd help mds
This commit is contained in:
onyx-and-iris 2026-02-11 21:47:56 +00:00
parent 32a09db1a4
commit 58866b794b
8 changed files with 70 additions and 21 deletions

View File

@ -46,9 +46,10 @@ type CLI struct {
Version VersionFlag `help:"Print x32-cli version information and quit" name:"version" short:"v"` 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"` Main MainCmdGroup `help:"Control the Main L/R output" cmd:"" group:"Main"`
Mainmono MainMonoCmdGroup `help:"Control the Main Mono output" cmd:"" group:"MainMono"` Mainmono MainMonoCmdGroup `help:"Control the Main Mono output" cmd:"" group:"MainMono"`
Matrix MatrixCmdGroup `help:"Control the matrix outputs." cmd:"" group:"Matrix"` Matrix MatrixCmdGroup `help:"Control the matrix outputs." cmd:"" group:"Matrix"`

18
cmd/x32-cli/info.go Normal file
View File

@ -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
}

View File

@ -46,9 +46,10 @@ type CLI struct {
Version VersionFlag `help:"Print xair-cli version information and quit" name:"version" short:"v"` 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"` 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"`

18
cmd/xair-cli/info.go Normal file
View File

@ -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
}

View File

@ -28,7 +28,7 @@ func NewXAirClient(mixerIP string, mixerPort int, opts ...EngineOption) (*XAirCl
} }
c := &XAirClient{ c := &XAirClient{
client: client{e}, client: client{e, InfoResponse{}},
} }
c.Main = newMainStereo(&c.client) c.Main = newMainStereo(&c.client)
c.Strip = newStrip(&c.client) c.Strip = newStrip(&c.client)
@ -61,7 +61,7 @@ func NewX32Client(mixerIP string, mixerPort int, opts ...EngineOption) (*X32Clie
} }
c := &X32Client{ c := &X32Client{
client: client{e}, client: client{e, InfoResponse{}},
} }
c.Main = newMainStereo(&c.client) c.Main = newMainStereo(&c.client)
c.MainMono = newMainMono(&c.client) c.MainMono = newMainMono(&c.client)
@ -77,6 +77,7 @@ func NewX32Client(mixerIP string, mixerPort int, opts ...EngineOption) (*X32Clie
type client struct { type client struct {
*engine *engine
Info InfoResponse
} }
// Start begins listening for messages in a goroutine // Start begins listening for messages in a goroutine
@ -124,11 +125,22 @@ func (c *client) RequestInfo() (InfoResponse, error) {
if err != nil { if err != nil {
return info, err return info, err
} }
if len(msg.Arguments) >= 3 { if len(msg.Arguments) == 4 {
info.Host = msg.Arguments[0].(string) if host, ok := msg.Arguments[0].(string); ok {
info.Name = msg.Arguments[1].(string) info.Host = host
info.Model = msg.Arguments[2].(string)
} }
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 return info, nil
} }

View File

@ -4,4 +4,5 @@ type InfoResponse struct {
Host string Host string
Name string Name string
Model string Model string
Firmware string
} }

View File

@ -12,9 +12,8 @@ Flags:
-v, --version Print x32-cli version information and quit -v, --version Print x32-cli version information and quit
Commands: Commands:
completion (c) Generate shell completion scripts. completion Generate shell completion scripts.
info Print mixer information.
Raw
raw Send raw OSC messages to the mixer. raw Send raw OSC messages to the mixer.
Main Main

View File

@ -12,9 +12,8 @@ Flags:
-v, --version Print xair-cli version information and quit -v, --version Print xair-cli version information and quit
Commands: Commands:
completion (c) Generate shell completion scripts. completion Generate shell completion scripts.
info Print mixer information.
Raw
raw Send raw OSC messages to the mixer. raw Send raw OSC messages to the mixer.
Main Main