-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslice_values_impl.go
More file actions
45 lines (38 loc) · 1.08 KB
/
Copy pathslice_values_impl.go
File metadata and controls
45 lines (38 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//go:generate mise exec -- genny -in=$GOFILE -out=gen.$GOFILE gen "DurationSlice=BoolSlice,StringArray,StringSlice,NotEmptyStringArray,NotEmptyStringSlice,OneOfStringSlice,EndpointSlice,IntSlice,Int64Slice,UintSlice,Uint64Slice,Float64Slice,IntBetweenSlice,PortSlice,ListenPortSlice,IPNetSlice,HostPortSlice"
//go:generate sed -i -e "\\,^//go:generate,d" gen.$GOFILE
package appcfg
import (
"fmt"
)
var _ Value = &DurationSlice{}
// String implements [flag.Value] interface.
func (v *DurationSlice) String() string {
if v == nil || v.values == nil {
return ""
}
return fmt.Sprint(v.values)
}
// Set implements [flag.Value] interface.
func (v *DurationSlice) Set(s string) error {
if v.completed {
v.completed = false
v.values = nil
}
err := v.set(s)
if err != nil {
v.values = nil
}
return err
}
// Get implements [flag.Getter] interface.
func (v *DurationSlice) Get() any {
if v.values == nil {
return nil
}
v.completed = true
return v.values
}
// Type implements [github.com/spf13/pflag.Value] interface.
func (*DurationSlice) Type() string {
return "DurationSlice"
}