nestedflagset

package
v0.0.0-...-1295c72 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 5 Imported by: 6

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlagSet

type FlagSet struct {
	F flag.FlagSet // The underlying FlagSet, populated on Parse.
}

FlagSet is a flag.Flag implementation that parses into a nested flag.FlagSet.

The FlagSet's flag value is parsed broken into a series of sub-options, which are then loaded into the nested flag set (FlagSet.F).

Example

ExampleFlagSet demonstrates nestedflagset.FlagSet usage.

nfs := &FlagSet{}
s := nfs.F.String("str", "", "Nested string option.")
i := nfs.F.Int("int", 0, "Nested integer option.")

if err := nfs.Parse(`str="Hello, world!",int=10`); err != nil {
	panic(err)
}
fmt.Printf("Parsed str=[%s], int=%d.\n", *s, *i)
Output:

Parsed str=[Hello, world!], int=10.

func (*FlagSet) Parse

func (fs *FlagSet) Parse(line string) error

Parse parses a one-line option string into the underlying flag set.

func (*FlagSet) Set

func (fs *FlagSet) Set(value string) error

Set implements flags.Value.

func (*FlagSet) String

func (fs *FlagSet) String() string

String implements flags.Value.

func (*FlagSet) Usage

func (fs *FlagSet) Usage() string

Usage constructs a one-line usage string for all of the options defined in Flags.

Jump to

Keyboard shortcuts

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