enum

package
v0.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package enum implements the generic logic to manage enum values for Cobra.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Enum

type Enum struct {
	Value string
	// contains filtered or unexported fields
}

Enum implements the flag interface. It can be used as a base for new flags that can have a limited set of values.

func NewEnum

func NewEnum(allowed []string, d string) *Enum

NewEnum returns an enum struct. The firs argument is a set of values allowed for the flag. The second argument is the default Value of the flag.

func (*Enum) Allowed

func (e *Enum) Allowed() string

Allowed returns the list of allowed values enclosed in parenthesis.

func (*Enum) Set

func (e *Enum) Set(p string) error

Set the Value for the flag.

func (*Enum) String

func (e *Enum) String() string

String returns the Value.

func (*Enum) Type

func (e *Enum) Type() string

Type returns the type of the flag.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL