add strip/bus name commands

This commit is contained in:
2026-02-01 00:50:24 +00:00
parent 4c4d52c74e
commit d894cc1317
3 changed files with 125 additions and 8 deletions

View File

@@ -223,6 +223,50 @@ var busFadeInCmd = &cobra.Command{
},
}
// busNameCmd represents the bus name command.
var busNameCmd = &cobra.Command{
Short: "Get or set the bus name",
Long: `Get or set the name of a specific bus.`,
Use: "name [bus number] [new name]",
Example: ` # Get the name of bus 1
xair-cli bus name 1
# Set the name of bus 1 to "Vocals"
xair-cli bus name 1 Vocals`,
Run: func(cmd *cobra.Command, args []string) {
client := ClientFromContext(cmd.Context())
if client == nil {
cmd.PrintErrln("OSC client not found in context")
return
}
if len(args) < 1 {
cmd.PrintErrln("Please provide bus number")
return
}
busIndex := mustConvToInt(args[0])
if len(args) == 1 {
name, err := client.Bus.Name(busIndex)
if err != nil {
cmd.PrintErrln("Error getting bus name:", err)
return
}
cmd.Printf("Bus %d name: %s\n", busIndex, name)
return
}
newName := args[1]
err := client.Bus.SetName(busIndex, newName)
if err != nil {
cmd.PrintErrln("Error setting bus name:", err)
return
}
cmd.Printf("Bus %d name set to: %s\n", busIndex, newName)
},
}
func init() {
rootCmd.AddCommand(busCmd)
@@ -233,4 +277,6 @@ func init() {
busFadeOutCmd.Flags().Float64P("duration", "d", 5.0, "Duration for fade out in seconds")
busCmd.AddCommand(busFadeInCmd)
busFadeInCmd.Flags().Float64P("duration", "d", 5.0, "Duration for fade in in seconds")
busCmd.AddCommand(busNameCmd)
}

View File

@@ -305,6 +305,54 @@ var stripSendCmd = &cobra.Command{
},
}
// stripNameCmd represents the strip name command.
var stripNameCmd = &cobra.Command{
Short: "Get or set the name of a strip",
Long: `Get or set the name of a specific strip.
If no name argument is provided, the current strip name is retrieved.
If a name argument is provided, the strip name is set to that value.`,
Use: "name [strip number] [name]",
Example: ` # Get the current name of strip 1
xair-cli strip name 1
# Set the name of strip 1 to "Guitar"
xair-cli strip name 1 "Guitar"`,
Run: func(cmd *cobra.Command, args []string) {
client := ClientFromContext(cmd.Context())
if client == nil {
cmd.PrintErrln("OSC client not found in context")
return
}
if len(args) < 1 {
cmd.PrintErrln("Please provide a strip number")
return
}
stripIndex := mustConvToInt(args[0])
if len(args) == 1 {
name, err := client.Strip.Name(stripIndex)
if err != nil {
cmd.PrintErrln("Error getting strip name:", err)
return
}
cmd.Printf("Strip %d name: %s\n", stripIndex, name)
return
}
name := args[1]
err := client.Strip.SetName(stripIndex, name)
if err != nil {
cmd.PrintErrln("Error setting strip name:", err)
return
}
cmd.Printf("Strip %d name set to: %s\n", stripIndex, name)
},
}
func init() {
rootCmd.AddCommand(stripCmd)
@@ -317,4 +365,6 @@ func init() {
stripFadeInCmd.Flags().Float64P("duration", "d", 5.0, "Duration of the fade in in seconds")
stripCmd.AddCommand(stripSendCmd)
stripCmd.AddCommand(stripNameCmd)
}