getopt

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlagSet

type FlagSet struct {
	*flag.FlagSet
	// contains filtered or unexported fields
}

func NewFlagSet

func NewFlagSet(name string, errorHandling flag.ErrorHandling) *FlagSet

NewFlagSet creates a new FlagSet with the specified name and error handling behavior.

func (*FlagSet) Alias

func (f *FlagSet) Alias(short, long string)

Alias creates an alias between two flag names. Either the short or the long name must be already defined. If both flags are defined or neither is defined, it panics.

func (*FlagSet) Bool

func (f *FlagSet) Bool(group string, name string, value bool, usage string) *bool

Bool defines a bool flag with specified name, default value, and usage string, and returns the address of a bool variable that stores the value of the flag.

func (*FlagSet) BoolVar

func (f *FlagSet) BoolVar(group string, p *bool, name string, value bool, usage string)

BoolVar defines a bool flag with specified name, default value, and usage string. The argument p points to a bool variable in which to store the value of the flag.

func (*FlagSet) DurationVar

func (f *FlagSet) DurationVar(group string, p *time.Duration, name string, value time.Duration, usage string)

DurationVar defines a time.Duration flag with specified name, default value, and usage string. The argument p points to a time.Duration variable in which to store the value of the flag.

func (*FlagSet) Float64Var

func (f *FlagSet) Float64Var(group string, p *float64, name string, value float64, usage string)

Float64Var defines a float64 flag with specified name, default value, and usage string. The argument p points to a float64 variable in which to store the value of the flag.

func (*FlagSet) Init

func (f *FlagSet) Init(name string, errorHandling flag.ErrorHandling)

Init initializes a FlagSet with the provided name and error handling behavior. This method is called by NewFlagSet and can also be called to reset an existing FlagSet.

func (*FlagSet) InitGroup

func (f *FlagSet) InitGroup(name, description string)

InitGroup initializes a new group of flags with the given name and description. Flags can be added to this group using the various flag definition methods.

func (*FlagSet) Int64Var

func (f *FlagSet) Int64Var(group string, p *int64, name string, value int64, usage string)

Int64Var defines an int64 flag with specified name, default value, and usage string. The argument p points to an int64 variable in which to store the value of the flag.

func (*FlagSet) IntVar

func (f *FlagSet) IntVar(group string, p *int, name string, value int, usage string)

IntVar defines an int flag with specified name, default value, and usage string. The argument p points to an int variable in which to store the value of the flag.

func (*FlagSet) Lookup

func (f *FlagSet) Lookup(name string) *flag.Flag

Lookup returns the Flag structure of the named command-line flag. Returns nil if the flag does not exist.

func (*FlagSet) Parse

func (f *FlagSet) Parse(args []string) error

Parse parses command-line arguments from args. Must be called after all flags are defined and before flags are accessed by the program.

func (*FlagSet) PrintDefaults

func (f *FlagSet) PrintDefaults()

PrintDefaults prints, to the output defined with SetOutput, the default values of all defined command-line flags in the FlagSet.

func (*FlagSet) SetExamples

func (f *FlagSet) SetExamples(examples string)

SetExamples sets a custom examples section for the FlagSet, to be displayed in usage output.

func (*FlagSet) SetOutput

func (f *FlagSet) SetOutput(output io.Writer)

SetOutput sets the destination for usage and error messages. If output is nil, os.Stderr is used.

func (*FlagSet) SetUsage

func (f *FlagSet) SetUsage(usage string)

SetUsage sets a custom usage message for the FlagSet.

func (*FlagSet) StringVar

func (f *FlagSet) StringVar(group string, p *string, name string, value string, usage string)

StringVar defines a string flag with specified name, default value, and usage string. The argument p points to a string variable in which to store the value of the flag.

func (*FlagSet) Uint64Var

func (f *FlagSet) Uint64Var(group string, p *uint64, name string, value uint64, usage string)

Uint64Var defines a uint64 flag with specified name, default value, and usage string. The argument p points to a uint64 variable in which to store the value of the flag.

func (*FlagSet) UintVar

func (f *FlagSet) UintVar(group string, p *uint, name string, value uint, usage string)

UintVar defines a uint flag with specified name, default value, and usage string. The argument p points to a uint variable in which to store the value of the flag.

func (*FlagSet) Var

func (f *FlagSet) Var(group string, value flag.Value, name string, usage string)

Var defines a flag with the specified name and usage string. The type and value of the flag are represented by the first argument, of type flag.Value.

Jump to

Keyboard shortcuts

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