-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathflag.go
More file actions
41 lines (32 loc) · 868 Bytes
/
flag.go
File metadata and controls
41 lines (32 loc) · 868 Bytes
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
package cmd
import "github.com/timescale/tiger-cli/internal/tiger/config"
// outputFlag implements the [github.com/spf13/pflag.Value] interface.
type outputFlag string
func (o *outputFlag) Set(val string) error {
if err := config.ValidateOutputFormat(val, false); err != nil {
return err
}
*o = outputFlag(val)
return nil
}
func (o *outputFlag) String() string {
return string(*o)
}
func (o *outputFlag) Type() string {
return "string"
}
// outputWithEnvFlag implements the [github.com/spf13/pflag.Value] interface.
type outputWithEnvFlag string
func (o *outputWithEnvFlag) Set(val string) error {
if err := config.ValidateOutputFormat(val, true); err != nil {
return err
}
*o = outputWithEnvFlag(val)
return nil
}
func (o *outputWithEnvFlag) String() string {
return string(*o)
}
func (o *outputWithEnvFlag) Type() string {
return "string"
}