flag

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnquoteUsage

func UnquoteUsage(f *Flag) (name string, usage string)

UnquoteUsage extracts a back-quoted name from the usage string for a flag and returns it and the un-quoted usage. Given "a `name` to show" it returns ("name", "a name to show"). If there are no back quotes, the name is an educated guess of the type of the flag's value, or the empty string if the flag is boolean.

Types

type Flag

type Flag struct {
	Name  string // full flag name
	Alias string // flag alias - if exists
	// contains filtered or unexported fields
}

func (*Flag) Help

func (f *Flag) Help() string

func (*Flag) Set

func (f *Flag) Set(s string) error

Set implements flag.ValueBefore interface and sets the struct field value.

func (*Flag) String

func (f *Flag) String() string

String implements flag.ValueBefore interface and gets the string value of the struct field.

func (*Flag) ValueType

func (f *Flag) ValueType() string

ValueType returns the string representation of the type in simple terms.

type GenHelpFunc

type GenHelpFunc func(preample, conclusion string, fGrps [][]*Flag) string

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

func NewLoader

func NewLoader(o Options) *Loader

func (*Loader) Load

func (l *Loader) Load(_ []byte, nGrps []*node.Nodes) error

func (*Loader) WithPrefix added in v0.6.0

func (l *Loader) WithPrefix(prefix string) *Loader

type Options

type Options struct {
	// HelpPreamble is optional text prepended to the help screen menu.
	HelpPreamble string

	// HelpPostamble is optional text appended to the generated help menu.
	HelpPostamble string

	// HelpFunc defines an optional custom help screen help menu render function to override the
	// default.
	HelpFunc GenHelpFunc
}

Jump to

Keyboard shortcuts

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