-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalue.go
35 lines (28 loc) · 854 Bytes
/
value.go
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
// SPDX-FileCopyrightText: 2025 The Cipher Host Team <[email protected]>
//
// SPDX-License-Identifier: MIT
package cmdkit
import (
"flag"
"strings"
)
// RepeatValue implements [flag.Value] to support repeated flag options. This
// allows flags to be specified multiple times to build a list of values.
//
// [flag.Value]: https://pkg.go.dev/flag#Value
type RepeatValue []string
// Compile-time check that RepeatValue implements the flag.Value interface.
var _ flag.Value = (*RepeatValue)(nil)
// String satisfies the [flag.Value] interface.
//
// [flag.Value]: https://pkg.go.dev/flag#Value
func (r *RepeatValue) String() string {
return strings.Join(*r, ", ")
}
// Set satisfies the [flag.Value] interface.
//
// [flag.Value]: https://pkg.go.dev/flag#Value
func (r *RepeatValue) Set(value string) error {
*r = append(*r, value)
return nil
}