flag

package
v0.0.0-...-a8d7af0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHelp

func AddHelp(seperator, help string)

AddHelp adds indented documentation to flag.Usage.

func CheckNoArgs

func CheckNoArgs() error

CheckNoArgs checks if any positional arguments were provided and if so, exit with error.

func FormatOptions

func FormatOptions(w io.Writer, header string, usageMap map[string]string)

FormatOptions writes a mapping of options to usage information that looks like standard Go help information. The header should end with a colon if options are provided.

Types

type Map

type Map map[string]string

Map is a type used to provide mapped options via command line flags. It implements the flag.Value interface. If a flag is passed without a value, for example: `-option somebool` it will still be initialized, so you can use `_, ok := option["somebool"]` to check if it exists.

func (Map) Clone

func (o Map) Clone() Map

Clone returns a copy of flag options

func (Map) Set

func (o Map) Set(value string) error

Set is the method to set the flag value, part of the flag.Value interface. Set's argument is a string to be parsed to set the flag. It still initializes flags that don't explicitly set a string

func (Map) String

func (o Map) String() string

String is the method to format the flag's value, part of the flag.Value interface. The String method's output is used in diagnostics.

func (Map) Type

func (o Map) Type() string

Type returns the golang type string. This method is required by pflag library.

type StringArrayOption

type StringArrayOption []string

StringArrayOption is a type used to provide string options via command line flags.

func (*StringArrayOption) Set

func (a *StringArrayOption) Set(value string) error

Set is the method to set the flag value, part of the flag.Value interface. Set's argument is a string to be parsed to set the flag.

func (*StringArrayOption) String

func (a *StringArrayOption) String() string

String is the method to format the flag's value, part of the flag.Value interface. The String method's output will be used in diagnostics.

Jump to

Keyboard shortcuts

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