diff options
Diffstat (limited to 'cmd/podman/validate/choice.go')
-rw-r--r-- | cmd/podman/validate/choice.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/cmd/podman/validate/choice.go b/cmd/podman/validate/choice.go index 572c5f4a5..8bb21c591 100644 --- a/cmd/podman/validate/choice.go +++ b/cmd/podman/validate/choice.go @@ -6,28 +6,28 @@ import ( ) // Honors cobra.Value interface -type choiceValue struct { +type ChoiceValue struct { value *string choices []string } -// ChoiceValue may be used in cobra FlagSet methods Var/VarP/VarPF() to select from a set of values +// Value may be used in cobra FlagSet methods Var/VarP/VarPF() to select from a set of values // // Example: // created := validate.ChoiceValue(&opts.Sort, "command", "created", "id", "image", "names", "runningfor", "size", "status") // flags.Var(created, "sort", "Sort output by: "+created.Choices()) -func ChoiceValue(p *string, choices ...string) *choiceValue { - return &choiceValue{ +func Value(p *string, choices ...string) *ChoiceValue { + return &ChoiceValue{ value: p, choices: choices, } } -func (c *choiceValue) String() string { +func (c *ChoiceValue) String() string { return *c.value } -func (c *choiceValue) Set(value string) error { +func (c *ChoiceValue) Set(value string) error { for _, v := range c.choices { if v == value { *c.value = value @@ -37,10 +37,10 @@ func (c *choiceValue) Set(value string) error { return fmt.Errorf("%q is not a valid value. Choose from: %q", value, c.Choices()) } -func (c *choiceValue) Choices() string { +func (c *ChoiceValue) Choices() string { return strings.Join(c.choices, ", ") } -func (c *choiceValue) Type() string { +func (c *ChoiceValue) Type() string { return "choice" } |