remove redundant util function

This commit is contained in:
onyx-and-iris 2026-02-05 04:15:21 +00:00
parent 1c5a75ffe1
commit c0b5d912b0
2 changed files with 4 additions and 17 deletions

View File

@ -134,8 +134,8 @@ func (cmd *StripFadeoutCmd) Run(ctx *context, strip *StripCmdGroup) error {
} }
type StripSendCmd struct { type StripSendCmd struct {
BusNum int `arg:"" help:"The bus number to get or set the send level for."` BusNum int `arg:"" help:"The bus number to get or set the send level for."`
Level *string `arg:"" help:"The send level to set (in dB)." optional:""` Level *float64 `arg:"" help:"The send level to set (in dB)." optional:""`
} }
func (cmd *StripSendCmd) Run(ctx *context, strip *StripCmdGroup) error { func (cmd *StripSendCmd) Run(ctx *context, strip *StripCmdGroup) error {
@ -148,11 +148,10 @@ func (cmd *StripSendCmd) Run(ctx *context, strip *StripCmdGroup) error {
return nil return nil
} }
level := mustConvToFloat64(*cmd.Level) if err := ctx.Client.Strip.SetSendLevel(strip.Index.Index, cmd.BusNum, *cmd.Level); err != nil {
if err := ctx.Client.Strip.SetSendLevel(strip.Index.Index, cmd.BusNum, level); err != nil {
return fmt.Errorf("failed to set send level: %w", err) return fmt.Errorf("failed to set send level: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d send level for bus %d set to: %.2f dB\n", strip.Index.Index, cmd.BusNum, level) fmt.Fprintf(ctx.Out, "Strip %d send level for bus %d set to: %.2f dB\n", strip.Index.Index, cmd.BusNum, *cmd.Level)
return nil return nil
} }

12
util.go
View File

@ -1,12 +0,0 @@
package main
import "strconv"
// mustConvToFloat64 converts a string to float64, panicking on error.
func mustConvToFloat64(floatStr string) float64 {
level, err := strconv.ParseFloat(floatStr, 64)
if err != nil {
panic(err)
}
return level
}