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

@ -135,7 +135,7 @@ func (cmd *StripFadeoutCmd) Run(ctx *context, strip *StripCmdGroup) error {
type StripSendCmd struct {
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 {
@ -148,11 +148,10 @@ func (cmd *StripSendCmd) Run(ctx *context, strip *StripCmdGroup) error {
return nil
}
level := mustConvToFloat64(*cmd.Level)
if err := ctx.Client.Strip.SetSendLevel(strip.Index.Index, cmd.BusNum, level); err != nil {
if err := ctx.Client.Strip.SetSendLevel(strip.Index.Index, cmd.BusNum, *cmd.Level); err != nil {
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
}

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
}