From c50fa6e91000c90490cd190442abc89a241dfad3 Mon Sep 17 00:00:00 2001 From: Dimitry Kolyshev Date: Mon, 9 Sep 2024 12:05:23 +0700 Subject: [PATCH] cmd: imp code --- internal/cmd/flag.go | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/internal/cmd/flag.go b/internal/cmd/flag.go index e61d8aff8..2669bcb0f 100644 --- a/internal/cmd/flag.go +++ b/internal/cmd/flag.go @@ -71,23 +71,18 @@ var _ flag.Value = (*intSliceValue)(nil) // Set implements the [flag.Value] interface for *intSliceValue. func (i *intSliceValue) Set(s string) (err error) { - values := strings.Split(s, ",") - - var intVal int64 - for _, v := range values { - intVal, err = strconv.ParseInt(v, 0, 32) - if err != nil { - return fmt.Errorf("parsing integer slice arg %q: %w", s, err) - } - - if !i.isSet { - i.isSet = true - *i.values = []int{} - } + intVal, err := strconv.ParseInt(s, 0, 32) + if err != nil { + return fmt.Errorf("parsing integer slice arg %q: %w", s, err) + } - *i.values = append(*i.values, int(intVal)) + if !i.isSet { + i.isSet = true + *i.values = []int{} } + *i.values = append(*i.values, int(intVal)) + return nil }