Skip to content

Commit

Permalink
cmd: parse better
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Aug 19, 2024
1 parent a44ba8c commit 3f18744
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions internal/cmd/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log/slog"
"os"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -36,16 +37,9 @@ var _ goFlags.Unmarshaler = (*decodableBool)(nil)
// UnmarshalFlag implements the [goFlags.Unmarshaler] interface for
// *decodableBool.
func (b *decodableBool) UnmarshalFlag(text string) (err error) {
switch text {
case "true":
b.value = true
case "false":
b.value = false
default:
return fmt.Errorf("invalid boolean value: %s", text)
}
b.value, err = strconv.ParseBool(text)

return nil
return err
}

// decodableDuration is a duration that can be unmarshaled from a flags.
Expand Down

0 comments on commit 3f18744

Please sign in to comment.