From 2730f8dc5d7df0fac85768c30118547621606368 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Sat, 31 Jan 2026 22:26:31 +0000 Subject: [PATCH] reorganise command fields --- cmd/bus.go | 37 +++++++++++++--------------------- cmd/main.go | 49 ++++++++++++++++++++------------------------ cmd/strip.go | 57 +++++++++++++++++++--------------------------------- 3 files changed, 57 insertions(+), 86 deletions(-) diff --git a/cmd/bus.go b/cmd/bus.go index 7ed7450..be58048 100644 --- a/cmd/bus.go +++ b/cmd/bus.go @@ -8,9 +8,9 @@ import ( // busCmd represents the bus command. var busCmd = &cobra.Command{ - Use: "bus", Short: "Commands to control individual buses", Long: `Commands to control individual buses of the XAir mixer, including mute status.`, + Use: "bus", Run: func(cmd *cobra.Command, _ []string) { cmd.Help() }, @@ -18,9 +18,9 @@ var busCmd = &cobra.Command{ // busMuteCmd represents the bus mute command. var busMuteCmd = &cobra.Command{ - Use: "mute [bus number] [true|false]", Short: "Get or set the bus mute status", Long: `Get or set the mute status of a specific bus.`, + Use: "mute [bus number] [true|false]", Run: func(cmd *cobra.Command, args []string) { client := ClientFromContext(cmd.Context()) if client == nil { @@ -56,19 +56,16 @@ var busMuteCmd = &cobra.Command{ // busFaderCmd represents the bus fader command. var busFaderCmd = &cobra.Command{ - Use: "fader [bus number] [level in dB]", Short: "Get or set the bus fader level", Long: `Get or set the fader level of a specific bus. If no level argument is provided, the current fader level is retrieved. -If a level argument (in dB) is provided, the bus fader is set to that level. - -For example: - # Get the current fader level of bus 1 +If a level argument (in dB) is provided, the bus fader is set to that level.`, + Use: "fader [bus number] [level in dB]", + Example: ` # Get the current fader level of bus 1 xair-cli bus fader 1 # Set the fader level of bus 1 to -10.0 dB - xair-cli bus fader 1 -10.0 - `, + xair-cli bus fader 1 -10.0`, Run: func(cmd *cobra.Command, args []string) { client := ClientFromContext(cmd.Context()) if client == nil { @@ -106,14 +103,11 @@ For example: // busFadeOutCmd represents the bus fade out command. var busFadeOutCmd = &cobra.Command{ - Use: "fadeout [bus number] --duration [seconds] [target level in dB]", Short: "Fade out the bus fader over a specified duration", - Long: `Fade out the bus fader to minimum level over a specified duration in seconds. - -For example: - # Fade out bus 1 over 5 seconds - xair-cli bus fadeout 1 --duration 5 -- -90.0 -`, + Long: "Fade out the bus fader to minimum level over a specified duration in seconds.", + Use: "fadeout [bus number] --duration [seconds] [target level in dB]", + Example: ` # Fade out bus 1 over 5 seconds + xair-cli bus fadeout 1 --duration 5 -- -90.0`, Run: func(cmd *cobra.Command, args []string) { client := ClientFromContext(cmd.Context()) if client == nil { @@ -170,14 +164,11 @@ For example: // BusFadeInCmd represents the bus fade in command. var busFadeInCmd = &cobra.Command{ - Use: "fadein [bus number] --duration [seconds] [target level in dB]", Short: "Fade in the bus fader over a specified duration", - Long: `Fade in the bus fader to maximum level over a specified duration in seconds. - -For example: - # Fade in bus 1 over 5 seconds - xair-cli bus fadein 1 --duration 5 -- 0.0 -`, + Long: "Fade in the bus fader to maximum level over a specified duration in seconds.", + Use: "fadein [bus number] --duration [seconds] [target level in dB]", + Example: ` # Fade in bus 1 over 5 seconds + xair-cli bus fadein 1 --duration 5 -- 0.0`, Run: func(cmd *cobra.Command, args []string) { client := ClientFromContext(cmd.Context()) if client == nil { diff --git a/cmd/main.go b/cmd/main.go index fe4965c..72b7797 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -8,9 +8,9 @@ import ( // mainCmd represents the main command. var mainCmd = &cobra.Command{ - Use: "main", Short: "Commands to control the main output", Long: `Commands to control the main output of the XAir mixer, including fader level and mute status.`, + Use: "main", Run: func(cmd *cobra.Command, _ []string) { cmd.Help() }, @@ -18,24 +18,21 @@ var mainCmd = &cobra.Command{ // mainMuteCmd represents the main mute command. var mainMuteCmd = &cobra.Command{ - Use: "mute [true|false]", Short: "Get or set the main LR mute status", Long: `Get or set the main L/R mute status. If no argument is provided, the current mute status is retrieved. If "true" or "1" is provided as an argument, the main output is muted. -If "false" or "0" is provided, the main output is unmuted. - -For example: - # Get the current main LR mute status +If "false" or "0" is provided, the main output is unmuted.`, + Use: "mute [true|false]", + Example: ` # Get the current main LR mute status xair-cli main mute # Mute the main output xair-cli main mute true # Unmute the main output - xair-cli main mute false -`, + xair-cli main mute false`, Run: func(cmd *cobra.Command, args []string) { client := ClientFromContext(cmd.Context()) if client == nil { @@ -54,8 +51,14 @@ For example: } var muted bool - if args[0] == "true" || args[0] == "1" { + switch args[0] { + case "true", "1": muted = true + case "false", "0": + muted = false + default: + cmd.PrintErrln("Invalid mute status. Use true/false or 1/0") + return } err := client.Main.SetMute(muted) @@ -69,20 +72,17 @@ For example: // mainFaderCmd represents the main fader command. var mainFaderCmd = &cobra.Command{ - Use: "fader [level in dB]", Short: "Set or get the main LR fader level", Long: `Set or get the main L/R fader level in dB. If no argument is provided, the current fader level is retrieved. -If a dB value is provided as an argument, the fader level is set to that value. - -For example: - # Get the current main LR fader level +If a dB value is provided as an argument, the fader level is set to that value.`, + Use: "fader [level in dB]", + Example: ` # Get the current main LR fader level xair-cli main fader # Set the main LR fader level to -10.0 dB - xair-cli main fader -- -10.0 -`, + xair-cli main fader -- -10.0`, Run: func(cmd *cobra.Command, args []string) { client := ClientFromContext(cmd.Context()) if client == nil { @@ -111,16 +111,14 @@ For example: // mainFadeOutCmd represents the main fadeout command. var mainFadeOutCmd = &cobra.Command{ - Use: "fadeout --duration [seconds] [target_db]", Short: "Fade out the main output", Long: `Fade out the main output over a specified duration. -For example: - -xair-cli main fadeout --duration 10 -- -20.0 -xair-cli main fadeout -- -90.0 # Uses default 5 second duration This command will fade out the main output to the specified dB level. `, + Use: "fadeout --duration [seconds] [target_db]", + Example: ` # Fade out main output over 5 seconds + xair-cli main fadeout --duration 5 -- -90.0`, Run: func(cmd *cobra.Command, args []string) { client := ClientFromContext(cmd.Context()) if client == nil { @@ -171,17 +169,14 @@ This command will fade out the main output to the specified dB level. // mainFadeInCmd represents the main fadein command. var mainFadeInCmd = &cobra.Command{ - Use: "fadein --duration [seconds] [target_db]", Short: "Fade in the main output", Long: `Fade in the main output over a specified duration. -For example: - -xair-cli main fadein --duration 10 -- -6.0 -xair-cli main fadein -- -0.0 # Uses default 5 second duration - This command will fade in the main output to the specified dB level. `, + Use: "fadein --duration [seconds] [target_db]", + Example: ` # Fade in main output over 5 seconds + xair-cli main fadein --duration 5 -- 0.0`, Run: func(cmd *cobra.Command, args []string) { client := ClientFromContext(cmd.Context()) if client == nil { diff --git a/cmd/strip.go b/cmd/strip.go index 71fe077..b62d841 100644 --- a/cmd/strip.go +++ b/cmd/strip.go @@ -8,9 +8,9 @@ import ( // stripCmd represents the strip command. var stripCmd = &cobra.Command{ - Use: "strip", Short: "Commands to control individual strips", Long: `Commands to control individual strips of the XAir mixer, including fader level and mute status.`, + Use: "strip", Run: func(cmd *cobra.Command, _ []string) { cmd.Help() }, @@ -18,23 +18,20 @@ var stripCmd = &cobra.Command{ // stripMuteCmd represents the strip mute command. var stripMuteCmd = &cobra.Command{ - Use: "mute [strip number] [true|false]", Short: "Get or set the mute status of a strip", Long: `Get or set the mute status of a specific strip. If no argument is provided, the current mute status is retrieved. If "true" or "1" is provided as an argument, the strip is muted. -If "false" or "0" is provided, the strip is unmuted. - -For example: - # Get the current mute status of strip 1 +If "false" or "0" is provided, the strip is unmuted.`, + Use: "mute [strip number] [true|false]", + Example: ` # Get the current mute status of strip 1 xair-cli strip mute 1 # Mute strip 1 xair-cli strip mute 1 true # Unmute strip 1 - xair-cli strip mute 1 false -`, + xair-cli strip mute 1 false`, Run: func(cmd *cobra.Command, args []string) { client := ClientFromContext(cmd.Context()) if client == nil { @@ -85,20 +82,17 @@ For example: // stripFaderCmd represents the strip fader command. var stripFaderCmd = &cobra.Command{ - Use: "fader [strip number] [level in dB]", Short: "Get or set the fader level of a strip", Long: `Get or set the fader level of a specific strip. If no level argument is provided, the current fader level is retrieved. -If a level argument (in dB) is provided, the strip fader is set to that level. - -For example: - # Get the current fader level of strip 1 +If a level argument (in dB) is provided, the strip fader is set to that level.`, + Use: "fader [strip number] [level in dB]", + Example: ` # Get the current fader level of strip 1 xair-cli strip fader 1 # Set the fader level of strip 1 to -10.0 dB - xair-cli strip fader 1 -10.0 -`, + xair-cli strip fader 1 -10.0`, Run: func(cmd *cobra.Command, args []string) { client := ClientFromContext(cmd.Context()) if client == nil { @@ -141,14 +135,11 @@ For example: // stripFadeOutCmd represents the strip fade out command. var stripFadeOutCmd = &cobra.Command{ - Use: "fadeout [strip number] --duration [seconds] [target level in dB]", Short: "Fade out the strip over a specified duration", - Long: `Fade out the strip over a specified duration in seconds. - -For example: - # Fade out strip 1 over 5 seconds - xair-cli strip fadeout 1 --duration 5.0 -- -90.0 -`, + Long: "Fade out the strip over a specified duration in seconds.", + Use: "fadeout [strip number] --duration [seconds] [target level in dB]", + Example: ` # Fade out strip 1 over 5 seconds + xair-cli strip fadeout 1 --duration 5.0 -- -90.0`, Run: func(cmd *cobra.Command, args []string) { client := ClientFromContext(cmd.Context()) if client == nil { @@ -204,14 +195,11 @@ For example: // stripFadeInCmd represents the strip fade in command. var stripFadeInCmd = &cobra.Command{ - Use: "fadein [strip number] --duration [seconds] [target level in dB]", Short: "Fade in the strip over a specified duration", - Long: `Fade in the strip over a specified duration in seconds. - -For example: - # Fade in strip 1 over 5 seconds - xair-cli strip fadein 1 --duration 5.0 0 -`, + Long: "Fade in the strip over a specified duration in seconds.", + Use: "fadein [strip number] --duration [seconds] [target level in dB]", + Example: ` # Fade in strip 1 over 5 seconds + xair-cli strip fadein 1 --duration 5.0 0`, Run: func(cmd *cobra.Command, args []string) { client := ClientFromContext(cmd.Context()) if client == nil { @@ -267,17 +255,14 @@ For example: // stripSendCmd represents the strip send command. var stripSendCmd = &cobra.Command{ - Use: "send [strip number] [bus number] [level in dB]", Short: "Commands to get or set strip send levels", - Long: `Commands to get or set the send levels for individual strips. - -For example: - # Get the send level of strip 1 to bus 1 + Long: "Commands to get or set the send levels for individual strips.", + Use: "send [strip number] [bus number] [level in dB]", + Example: ` # Get the send level of strip 1 to bus 1 xair-cli strip send 1 1 # Set the send level of strip 1 to bus 1 to -5.0 dB - xair-cli strip send 1 1 -- -5.0 -`, + xair-cli strip send 1 1 -- -5.0`, Run: func(cmd *cobra.Command, args []string) { client := ClientFromContext(cmd.Context()) if client == nil {