pflag

package module
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: BSD-3-Clause Imports: 15 Imported by: 8

README

pflag

This is a fork of spf13/pflag due to poor maintenance

GoDoc Go Report Card GitHub release (latest SemVer) Build Status

Installation

pflag is available using the standard go get command.

Install by running:

go get github.com/lynxsecurity/pflag
Installing this fork with spf13/cobra

Initialize your new app as normal

cobra init myAwesomeCli --pkg-name github.com/username/repo
cd myAwesomeCli
go mod init github.com/username/repo
go mod tidy
go mod vendor

Override the upstream module using the newest release.

pflag_upstream="github.com/spf13/pflag"
pflag_fork="github.com/lynxsecurity/pflag"
pflag_fork_release="$(curl -s https://api.github.com/repos/lynxsecurity/pflag/tags \
  | grep -o '"name": ".*"' \
  | head -1 \
  | cut -d':' -f2 \
  | tr -d '" ')"
go mod edit -replace $pflag_upstream=$pflag_fork@$pflag_fork_release

Supported Syntax

--flag    // boolean flags, or flags with no option default values
--flag x  // only on flags without a default value
--flag=x

Unlike the flag package, a single dash before an option means something different than a double dash. Single dashes signify a series of shorthand letters for flags. All but the last shorthand letter must be boolean flags or a flag with a default value

// boolean or flags where the 'no option default value' is set
-f
-f=true
-abc
but
-b true is INVALID

// non-boolean and flags without a 'no option default value'
-n 1234
-n=1234
-n1234

// mixed
-abcs "hello"
-absd="hello"
-abcs1234

Slice flags can be specified multiple times, or specified with an equal sign and csv.

--sliceVal one --sliceVal=two
--sliceVal=one,two

Integer flags accept 1234, 0664, 0x1234 and may be negative. Boolean flags (in their long form) accept 1, 0, t, f, true, false, TRUE, FALSE, True, False. Duration flags accept any input valid for time.ParseDuration.

Flag parsing stops after the terminator "--". Unlike the flag package, flags can be interspersed with arguments anywhere on the command line before this terminator.

Documentation

You can see the full reference documentation of the pflag package at godoc.org, querying with go doc, or through go's standard documentation system by running godoc -http=:6060 and browsing to http://localhost:6060/pkg/github.com/lynxsecurity/pflag after installation.

Set a custom default for flags passed without values

If a flag has a NoOptDefVal and the flag is set on the command line without an option, the flag will be set to the NoOptDefVal.

Example:

var ip = flag.IntP("flagname", "f", 1234, "help message")
flag.Lookup("flagname").NoOptDefVal = "4321"

Results:

Parsed Arguments Resulting Value
--flagname=1357 ip=1357
--flagname ip=4321
[nothing] ip=1234
Mutating or "Normalizing" Flag names

It is possible to set a custom flag name 'normalization function.' It allows flag names to be mutated both when created in the code and when used on the command line to some 'normalized' form. The 'normalized' form is used for comparison. Two examples of using the custom normalization func follow.

Example #1: You want -, _, and . in flags to compare the same. aka --my-flag == --my_flag == --my.flag

func wordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName {
	from := []string{"-", "_"}
	to := "."
	for _, sep := range from {
		name = strings.Replace(name, sep, to, -1)
	}
	return pflag.NormalizedName(name)
}

myFlagSet.SetNormalizeFunc(wordSepNormalizeFunc)

Example #2: You want to alias two flags. aka --old-flag-name == --new-flag-name

func aliasNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName {
	switch name {
	case "old-flag-name":
		name = "new-flag-name"
		break
	}
	return pflag.NormalizedName(name)
}

myFlagSet.SetNormalizeFunc(aliasNormalizeFunc)
Deprecating a flag or its shorthand

It is possible to deprecate a flag, or just its shorthand. Deprecating a flag/shorthand hides it from help text and prints a usage message when the deprecated flag/shorthand is used.

Example #1: You want to deprecate a flag named "badflag" as well as inform the users what flag they should use instead.

// deprecate a flag by specifying its name and a usage message
flags.MarkDeprecated("badflag", "please use --good-flag instead")

This hides "badflag" from help text, and prints Flag --badflag has been deprecated, please use --good-flag instead when "badflag" is used.

Example #2: You want to keep a flag name "noshorthandflag" but deprecate it's shortname "n".

// deprecate a flag shorthand by specifying its flag name and a usage message
flags.MarkShorthandDeprecated("noshorthandflag", "please use --noshorthandflag only")

This hides the shortname "n" from help text, and prints Flag shorthand -n has been deprecated, please use --noshorthandflag only when the shorthand "n" is used.

Note that usage message is essential here, and it should not be empty.

Hidden flags

It is possible to mark a flag as hidden, meaning it will still function as normal, however will not show up in usage/help text.

Example: You have a flag named "secretFlag" that you need for internal use only and don't want it showing up in help text, or for its usage text to be available.

// hide a flag by specifying its name
flags.MarkHidden("secretFlag")
Disable sorting of flags

It is possible to disable sorting of flags for help and usage message.

Example:

flag.BoolP("verbose", "v", false, "verbose output")
flag.String("coolflag", "yeaah", "it's really cool flag")
flag.Int("usefulflag", 777, "sometimes it's very useful")
flag.SortFlags = false
flag.PrintDefaults()

Output:

  -v, --verbose           verbose output
      --coolflag string   it's really cool flag (default "yeaah")
      --usefulflag int    sometimes it's very useful (default 777)
Supporting Go flags when using pflag

In order to support flags defined using Go's flag package, they must be added to the pflag flagset. This is usually necessary to support flags defined by third-party dependencies (e.g. golang/glog).

Example: You want to add the Go flags to the CommandLine flagset

import (
	goflag "flag"
	flag "github.com/lynxsecurity/pflag"
)

var ip *int = flag.Int("flagname", 1234, "help message for flagname")

func main() {
	flag.CommandLine.AddGoFlagSet(goflag.CommandLine)
	flag.Parse()
}
Shorthand flags

A flag supporting both long and short formats can be created with any of the flag functions suffixed with P:

flag.BoolP("toggle", "t", false, "toggle help message")
Shorthand-only flags

A shorthand-only flag can be created with any of the flag functions suffixed with S:

flag.StringS("value", "l", "", "value help message")

This flag can be looked up using it's long name, but will only be parsed when the short form is passed.

Unknown flags

Normally pflag will error when an unknown flag is passed, but it's also possible to disable that using FlagSet.ParseErrorsWhitelist.UnknownFlags:

flags.ParseErrorsWhitelist.UnknownFlags = true
flag.Parse()

These can then be obtained as a slice of strings using FlagSet.GetUnknownFlags().

Custom flag types in usage

There are two methods to set a custom type to be printed in the usage.

First, it's possible to set explicitly with CustomUsageType:

flag.String("character", "", "character name")
flag.Lookup("character").CustomUsageType = "enum"

Output:

  --character enum   character name (default "")

Alternatively, it's possbile to include backticks around a single word in the usage string, which will be extracted and printed with the usage:

flag.String("character", "", "`character` name")

Output:

  --character character   character name (default "")

Note: This unquoting behavior can be disabled with Flag.DisableUnquoteUsage.

Disable printing a flag's default value

The printing of a flag's default value can be suppressed with Flag.DisablePrintDefault.

Example:

flag.Int("in", -1, "help message")
flag.Lookup("in").DisablePrintDefault = true

Output:

  --in int   help message
Disable built-in help flags

Normally pflag will handle --help and -h when the flags aren't explicitly defined.

If for some reason there is a need to capture the error returned in this condition, it is possible to disable this built-in handling.

myFlagSet.DisableBuiltinHelp = true

Documentation

Overview

Package pflag is a drop-in replacement of Go's native flag package, implementing POSIX/GNU-style --flags. pflag is compatible with the GNU extensions to the POSIX recommendations for command-line options. See http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html

pflag is available under the same style of BSD license as the Go language, which can be found in the LICENSE file.

If you import pflag under the name "flag" then all code should continue to function with no changes.

import flag "github.com/lynxsecurity/pflag"

There is one exception to this: if you directly instantiate the Flag struct there is one more field "Shorthand" that you will need to set. Most code never instantiates this struct directly, and instead uses functions such as String(), BoolVar(), and Var(), and is therefore unaffected.

Define flags using flag.String(), Bool(), Int(), etc.

This declares an integer flag, -flagname, stored in the pointer ip, with type *int.

var ip = flag.Int("flagname", 1234, "help message for flagname")

If you like, you can bind the flag to a variable using the Var() functions.

var flagvar int
func init() {
	flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname")
}

Or you can create custom flags that satisfy the Value interface (with pointer receivers) and couple them to flag parsing by

flag.Var(&flagVal, "name", "help message for flagname")

For such flags, the default value is just the initial value of the variable.

After all flags are defined, call

flag.Parse()

to parse the command line into the defined flags.

Flags may then be used directly. If you're using the flags themselves, they are all pointers; if you bind to variables, they're values.

fmt.Println("ip has value ", *ip)
fmt.Println("flagvar has value ", flagvar)

After parsing, the arguments after the flag are available as the slice flag.Args() or individually as flag.Arg(i). The arguments are indexed from 0 through flag.NArg()-1.

The pflag package also defines some new functions that are not in flag, that give one-letter shorthands for flags. You can use these by appending 'P' to the name of any function that defines a flag.

var ip = flag.IntP("flagname", "f", 1234, "help message")
var flagvar bool
func init() {
	flag.BoolVarP(&flagvar, "boolname", "b", true, "help message")
}
flag.VarP(&flagval, "varname", "v", "help message")

Shorthand letters can be used with single dashes on the command line. Boolean shorthand flags can be combined with other shorthand flags.

Command line flag syntax:

--flag    // boolean flags only
--flag=x

Unlike the flag package, a single dash before an option means something different than a double dash. Single dashes signify a series of shorthand letters for flags. All but the last shorthand letter must be boolean flags.

// boolean flags
-f
-abc
// non-boolean flags
-n 1234
-Ifile
// mixed
-abcs "hello"
-abcn1234

Flag parsing stops after the terminator "--". Unlike the flag package, flags can be interspersed with arguments anywhere on the command line before this terminator.

Integer flags accept 1234, 0664, 0x1234 and may be negative. Boolean flags (in their long form) accept 1, 0, t, f, true, false, TRUE, FALSE, True, False. Duration flags accept any input valid for time.ParseDuration.

The default set of command-line flags is controlled by top-level functions. The FlagSet type allows one to define independent sets of flags, such as to implement subcommands in a command-line interface. The methods of FlagSet are analogous to the top-level functions for the command-line flag set.

Index

Examples

Constants

This section is empty.

Variables

View Source
var CommandLine = NewFlagSet(os.Args[0], ExitOnError)

CommandLine is the default set of command-line flags, parsed from os.Args.

View Source
var ErrHelp = errors.New("pflag: help requested")

ErrHelp is the error returned if the flag -help is invoked but no such flag is defined.

View Source
var Usage = func() {
	fmt.Fprintf(CommandLine.Output(), "Usage of %s:\n", os.Args[0])
	PrintDefaults()
}

Usage prints to standard error a usage message documenting all defined command-line flags. The function is a variable that may be changed to point to a custom function. By default it prints a simple header and calls PrintDefaults; for details about the format of the output and how to control it, see the documentation for PrintDefaults.

Functions

func Arg

func Arg(i int) string

Arg returns the i'th command-line argument. Arg(0) is the first remaining argument after flags have been processed.

func Args

func Args() []string

Args returns the non-flag command-line arguments.

func Bool

func Bool(name string, value bool, usage string) *bool

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

func BoolP

func BoolP(name, shorthand string, value bool, usage string) *bool

BoolP is like Bool, but accepts a shorthand letter that can be used after a single dash.

func BoolS added in v1.1.3

func BoolS(name string, shorthand string, value bool, usage string) *bool

BoolS is like Bool, but accepts a shorthand letter to be used after a single dash, alone.

func BoolSlice

func BoolSlice(name string, value []bool, usage string) *[]bool

BoolSlice defines a []bool flag with specified name, default value, and usage string. The return value is the address of a []bool variable that stores the value of the flag.

func BoolSliceP

func BoolSliceP(name, shorthand string, value []bool, usage string) *[]bool

BoolSliceP is like BoolSlice, but accepts a shorthand letter that can be used after a single dash.

func BoolSliceS added in v1.1.3

func BoolSliceS(name string, shorthand string, value []bool, usage string) *[]bool

BoolSliceS is like BoolSlice, but accepts a shorthand letter that can be used after a single dash, alone.

func BoolSliceVar

func BoolSliceVar(p *[]bool, name string, value []bool, usage string)

BoolSliceVar 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 BoolSliceVarP

func BoolSliceVarP(p *[]bool, name, shorthand string, value []bool, usage string)

BoolSliceVarP is like BoolSliceVar, but accepts a shorthand letter that can be used after a single dash.

func BoolSliceVarS added in v1.1.3

func BoolSliceVarS(p *[]bool, name string, shorthand string, value []bool, usage string)

BoolSliceVarS is like BoolSliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func BoolVar

func BoolVar(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 BoolVarP

func BoolVarP(p *bool, name, shorthand string, value bool, usage string)

BoolVarP is like BoolVar, but accepts a shorthand letter that can be used after a single dash.

func BoolVarS added in v1.1.3

func BoolVarS(p *bool, name string, shorthand string, value bool, usage string)

BoolVarS is like BoolVar, but accepts a shorthand letter to be used after a single dash, alone.

func BytesBase64 added in v1.0.2

func BytesBase64(name string, value []byte, usage string) *[]byte

BytesBase64 defines an []byte flag with specified name, default value, and usage string. The return value is the address of an []byte variable that stores the value of the flag.

func BytesBase64P added in v1.0.2

func BytesBase64P(name, shorthand string, value []byte, usage string) *[]byte

BytesBase64P is like BytesBase64, but accepts a shorthand letter that can be used after a single dash.

func BytesBase64S added in v1.1.3

func BytesBase64S(name, shorthand string, value []byte, usage string) *[]byte

BytesBase64S is like BytesBase64, but accepts a shorthand letter that can be used after a single dash, alone.

func BytesBase64Var added in v1.0.2

func BytesBase64Var(p *[]byte, name string, value []byte, usage string)

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

func BytesBase64VarP added in v1.0.2

func BytesBase64VarP(p *[]byte, name, shorthand string, value []byte, usage string)

BytesBase64VarP is like BytesBase64Var, but accepts a shorthand letter that can be used after a single dash.

func BytesBase64VarS added in v1.1.3

func BytesBase64VarS(p *[]byte, name, shorthand string, value []byte, usage string)

BytesBase64VarS is like BytesBase64Var, but accepts a shorthand letter that can be used after a single dash, alone.

func BytesHex added in v1.0.1

func BytesHex(name string, value []byte, usage string) *[]byte

BytesHex defines an []byte flag with specified name, default value, and usage string. The return value is the address of an []byte variable that stores the value of the flag.

func BytesHexP added in v1.0.1

func BytesHexP(name, shorthand string, value []byte, usage string) *[]byte

BytesHexP is like BytesHex, but accepts a shorthand letter that can be used after a single dash.

func BytesHexS added in v1.1.3

func BytesHexS(name, shorthand string, value []byte, usage string) *[]byte

BytesHexS is like BytesHexP, but accepts a shorthand letter that can be used after a single dash, alone.

func BytesHexVar added in v1.0.1

func BytesHexVar(p *[]byte, name string, value []byte, usage string)

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

func BytesHexVarP added in v1.0.1

func BytesHexVarP(p *[]byte, name, shorthand string, value []byte, usage string)

BytesHexVarP is like BytesHexVar, but accepts a shorthand letter that can be used after a single dash.

func BytesHexVarS added in v1.1.3

func BytesHexVarS(p *[]byte, name, shorthand string, value []byte, usage string)

BytesHexVarS is like BytesHexVarP, but accepts a shorthand letter that can be used after a single dash, alone.

func Complex128 added in v1.1.3

func Complex128(name string, value complex128, usage string) *complex128

Complex128 defines a complex128 flag with specified name, default value, and usage string. The return value is the address of a complex128 variable that stores the value of the flag.

func Complex128P added in v1.1.3

func Complex128P(name, shorthand string, value complex128, usage string) *complex128

Complex128P is like Complex128, but accepts a shorthand letter that can be used after a single dash.

func Complex128S added in v1.1.3

func Complex128S(name, shorthand string, value complex128, usage string) *complex128

Complex128S is like Complex128, but accepts a shorthand letter that can be used after a single dash, alone.

func Complex128Slice added in v1.1.3

func Complex128Slice(name string, value []complex128, usage string) *[]complex128

Complex128Slice defines a []complex128 flag with specified name, default value, and usage string. The return value is the address of a []complex128 variable that stores the value of the flag.

func Complex128SliceP added in v1.1.3

func Complex128SliceP(name, shorthand string, value []complex128, usage string) *[]complex128

Complex128SliceP is like Complex128Slice, but accepts a shorthand letter that can be used after a single dash.

func Complex128SliceS added in v1.1.3

func Complex128SliceS(name, shorthand string, value []complex128, usage string) *[]complex128

Complex128SliceS is like Complex128Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func Complex128SliceVar added in v1.1.3

func Complex128SliceVar(p *[]complex128, name string, value []complex128, usage string)

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

func Complex128SliceVarP added in v1.1.3

func Complex128SliceVarP(p *[]complex128, name, shorthand string, value []complex128, usage string)

Complex128SliceVarP is like Complex128SliceVar, but accepts a shorthand letter that can be used after a single dash.

func Complex128SliceVarS added in v1.1.3

func Complex128SliceVarS(p *[]complex128, name, shorthand string, value []complex128, usage string)

Complex128SliceVarS is like Complex128SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func Complex128Var added in v1.1.3

func Complex128Var(p *complex128, name string, value complex128, usage string)

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

func Complex128VarP added in v1.1.3

func Complex128VarP(p *complex128, name, shorthand string, value complex128, usage string)

Complex128VarP is like Complex128Var, but accepts a shorthand letter that can be used after a single dash.

func Complex128VarS added in v1.1.3

func Complex128VarS(p *complex128, name, shorthand string, value complex128, usage string)

Complex128VarS is like Complex128Var, but accepts a shorthand letter that can be used after a single dash, alone.

func Count

func Count(name string, usage string) *int

Count defines a count flag with specified name, default value, and usage string. The return value is the address of an int variable that stores the value of the flag. A count flag will add 1 to its value evey time it is found on the command line

func CountP

func CountP(name, shorthand string, usage string) *int

CountP is like Count only takes a shorthand for the flag name.

func CountS added in v1.1.3

func CountS(name, shorthand string, usage string) *int

CountS is like Count only takes a shorthand for the flag name, alone.

func CountVar

func CountVar(p *int, name string, usage string)

CountVar like CountVar only the flag is placed on the CommandLine instead of a given flag set

func CountVarP

func CountVarP(p *int, name, shorthand string, usage string)

CountVarP is like CountVar only take a shorthand for the flag name.

func CountVarS added in v1.1.3

func CountVarS(p *int, name, shorthand string, usage string)

CountVarS is like CountVar only take a shorthand for the flag name, alone.

func Duration

func Duration(name string, value time.Duration, usage string) *time.Duration

Duration defines a time.Duration flag with specified name, default value, and usage string. The return value is the address of a time.Duration variable that stores the value of the flag.

func DurationP

func DurationP(name, shorthand string, value time.Duration, usage string) *time.Duration

DurationP is like Duration, but accepts a shorthand letter that can be used after a single dash.

func DurationS added in v1.1.3

func DurationS(name, shorthand string, value time.Duration, usage string) *time.Duration

DurationS is like Duration, but accepts a shorthand letter that can be used after a single dash, alone.

func DurationSlice added in v1.0.1

func DurationSlice(name string, value []time.Duration, usage string) *[]time.Duration

DurationSlice defines a []time.Duration flag with specified name, default value, and usage string. The return value is the address of a []time.Duration variable that stores the value of the flag.

func DurationSliceP added in v1.0.1

func DurationSliceP(name, shorthand string, value []time.Duration, usage string) *[]time.Duration

DurationSliceP is like DurationSlice, but accepts a shorthand letter that can be used after a single dash.

func DurationSliceS added in v1.1.3

func DurationSliceS(name, shorthand string, value []time.Duration, usage string) *[]time.Duration

DurationSliceS is like DurationSlice, but accepts a shorthand letter that can be used after a single dash, alone.

func DurationSliceVar added in v1.0.1

func DurationSliceVar(p *[]time.Duration, name string, value []time.Duration, usage string)

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

func DurationSliceVarP added in v1.0.1

func DurationSliceVarP(p *[]time.Duration, name, shorthand string, value []time.Duration, usage string)

DurationSliceVarP is like DurationSliceVar, but accepts a shorthand letter that can be used after a single dash.

func DurationSliceVarS added in v1.1.3

func DurationSliceVarS(p *[]time.Duration, name, shorthand string, value []time.Duration, usage string)

DurationSliceVarS is like DurationSliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func DurationVar

func DurationVar(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 DurationVarP

func DurationVarP(p *time.Duration, name, shorthand string, value time.Duration, usage string)

DurationVarP is like DurationVar, but accepts a shorthand letter that can be used after a single dash.

func DurationVarS added in v1.1.3

func DurationVarS(p *time.Duration, name, shorthand string, value time.Duration, usage string)

DurationVarS is like DurationVar, but accepts a shorthand letter that can be used after a single dash, alone.

func Float32

func Float32(name string, value float32, usage string) *float32

Float32 defines a float32 flag with specified name, default value, and usage string. The return value is the address of a float32 variable that stores the value of the flag.

func Float32P

func Float32P(name, shorthand string, value float32, usage string) *float32

Float32P is like Float32, but accepts a shorthand letter that can be used after a single dash.

func Float32S added in v1.1.3

func Float32S(name, shorthand string, value float32, usage string) *float32

Float32S is like Float32, but accepts a shorthand letter that can be used after a single dash, alone.

func Float32Slice added in v1.1.3

func Float32Slice(name string, value []float32, usage string) *[]float32

Float32Slice defines a []float32 flag with specified name, default value, and usage string. The return value is the address of a []float32 variable that stores the value of the flag.

func Float32SliceP added in v1.1.3

func Float32SliceP(name, shorthand string, value []float32, usage string) *[]float32

Float32SliceP is like Float32Slice, but accepts a shorthand letter that can be used after a single dash.

func Float32SliceS added in v1.1.3

func Float32SliceS(name, shorthand string, value []float32, usage string) *[]float32

Float32SliceS is like Float32Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func Float32SliceVar added in v1.1.3

func Float32SliceVar(p *[]float32, name string, value []float32, usage string)

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

func Float32SliceVarP added in v1.1.3

func Float32SliceVarP(p *[]float32, name, shorthand string, value []float32, usage string)

Float32SliceVarP is like Float32SliceVar, but accepts a shorthand letter that can be used after a single dash.

func Float32SliceVarS added in v1.1.3

func Float32SliceVarS(p *[]float32, name, shorthand string, value []float32, usage string)

Float32SliceVarS is like Float32SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func Float32Var

func Float32Var(p *float32, name string, value float32, usage string)

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

func Float32VarP

func Float32VarP(p *float32, name, shorthand string, value float32, usage string)

Float32VarP is like Float32Var, but accepts a shorthand letter that can be used after a single dash.

func Float32VarS added in v1.1.3

func Float32VarS(p *float32, name, shorthand string, value float32, usage string)

Float32VarS is like Float32Var, but accepts a shorthand letter that can be used after a single dash, alone.

func Float64

func Float64(name string, value float64, usage string) *float64

Float64 defines a float64 flag with specified name, default value, and usage string. The return value is the address of a float64 variable that stores the value of the flag.

func Float64P

func Float64P(name, shorthand string, value float64, usage string) *float64

Float64P is like Float64, but accepts a shorthand letter that can be used after a single dash.

func Float64S added in v1.1.3

func Float64S(name, shorthand string, value float64, usage string) *float64

Float64S is like Float64, but accepts a shorthand letter that can be used after a single dash, alone.

func Float64Slice added in v1.1.3

func Float64Slice(name string, value []float64, usage string) *[]float64

Float64Slice defines a []float64 flag with specified name, default value, and usage string. The return value is the address of a []float64 variable that stores the value of the flag.

func Float64SliceP added in v1.1.3

func Float64SliceP(name, shorthand string, value []float64, usage string) *[]float64

Float64SliceP is like Float64Slice, but accepts a shorthand letter that can be used after a single dash.

func Float64SliceS added in v1.1.3

func Float64SliceS(name, shorthand string, value []float64, usage string) *[]float64

Float64SliceS is like Float64Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func Float64SliceVar added in v1.1.3

func Float64SliceVar(p *[]float64, name string, value []float64, usage string)

Float64SliceVar 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 Float64SliceVarP added in v1.1.3

func Float64SliceVarP(p *[]float64, name, shorthand string, value []float64, usage string)

Float64SliceVarP is like Float64SliceVar, but accepts a shorthand letter that can be used after a single dash.

func Float64SliceVarS added in v1.1.3

func Float64SliceVarS(p *[]float64, name, shorthand string, value []float64, usage string)

Float64SliceVarS is like Float64SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func Float64Var

func Float64Var(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 Float64VarP

func Float64VarP(p *float64, name, shorthand string, value float64, usage string)

Float64VarP is like Float64Var, but accepts a shorthand letter that can be used after a single dash.

func Float64VarS added in v1.1.3

func Float64VarS(p *float64, name, shorthand string, value float64, usage string)

Float64VarS is like Float64Var, but accepts a shorthand letter that can be used after a single dash, alone.

func GetUnknownFlags added in v1.1.3

func GetUnknownFlags() []string

GetUnknownFlags returns unknown command-line flags in the order they were Parsed. This requires ParseErrorsWhitelist.UnknownFlags to be set so that parsing does not abort on the first unknown flag.

func IP

func IP(name string, value net.IP, usage string) *net.IP

IP defines an net.IP flag with specified name, default value, and usage string. The return value is the address of an net.IP variable that stores the value of the flag.

func IPMask

func IPMask(name string, value net.IPMask, usage string) *net.IPMask

IPMask defines an net.IPMask flag with specified name, default value, and usage string. The return value is the address of an net.IPMask variable that stores the value of the flag.

func IPMaskP

func IPMaskP(name, shorthand string, value net.IPMask, usage string) *net.IPMask

IPMaskP is like IP, but accepts a shorthand letter that can be used after a single dash.

func IPMaskS added in v1.1.3

func IPMaskS(name, shorthand string, value net.IPMask, usage string) *net.IPMask

IPMaskS is like IP, but accepts a shorthand letter that can be used after a single dash, alone.

func IPMaskVar

func IPMaskVar(p *net.IPMask, name string, value net.IPMask, usage string)

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

func IPMaskVarP

func IPMaskVarP(p *net.IPMask, name, shorthand string, value net.IPMask, usage string)

IPMaskVarP is like IPMaskVar, but accepts a shorthand letter that can be used after a single dash.

func IPMaskVarS added in v1.1.3

func IPMaskVarS(p *net.IPMask, name, shorthand string, value net.IPMask, usage string)

IPMaskVarS is like IPMaskVar, but accepts a shorthand letter that can be used after a single dash, alone.

func IPNet

func IPNet(name string, value net.IPNet, usage string) *net.IPNet

IPNet defines an net.IPNet flag with specified name, default value, and usage string. The return value is the address of an net.IPNet variable that stores the value of the flag.

func IPNetP

func IPNetP(name, shorthand string, value net.IPNet, usage string) *net.IPNet

IPNetP is like IPNet, but accepts a shorthand letter that can be used after a single dash.

func IPNetS added in v1.1.3

func IPNetS(name, shorthand string, value net.IPNet, usage string) *net.IPNet

IPNetS is like IPNet, but accepts a shorthand letter that can be used after a single dash, alone.

func IPNetSlice added in v1.1.3

func IPNetSlice(name string, value []net.IPNet, usage string) *[]net.IPNet

IPNetSlice defines a []net.IPNet flag with specified name, default value, and usage string. The return value is the address of a []net.IP variable that stores the value of the flag.

func IPNetSliceP added in v1.1.3

func IPNetSliceP(name, shorthand string, value []net.IPNet, usage string) *[]net.IPNet

IPNetSliceP is like IPNetSlice, but accepts a shorthand letter that can be used after a single dash.

func IPNetSliceS added in v1.1.3

func IPNetSliceS(name, shorthand string, value []net.IPNet, usage string) *[]net.IPNet

IPNetSliceS is like IPNetSlice, but accepts a shorthand letter that can be used after a single dash, alone.

func IPNetSliceVar added in v1.1.3

func IPNetSliceVar(p *[]net.IPNet, name string, value []net.IPNet, usage string)

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

func IPNetSliceVarP added in v1.1.3

func IPNetSliceVarP(p *[]net.IPNet, name, shorthand string, value []net.IPNet, usage string)

IPNetSliceVarP is like IPNetSliceVar, but accepts a shorthand letter that can be used after a single dash.

func IPNetSliceVarS added in v1.1.3

func IPNetSliceVarS(p *[]net.IPNet, name, shorthand string, value []net.IPNet, usage string)

IPNetSliceVarS is like IPNetSliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func IPNetVar

func IPNetVar(p *net.IPNet, name string, value net.IPNet, usage string)

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

func IPNetVarP

func IPNetVarP(p *net.IPNet, name, shorthand string, value net.IPNet, usage string)

IPNetVarP is like IPNetVar, but accepts a shorthand letter that can be used after a single dash.

func IPNetVarS added in v1.1.3

func IPNetVarS(p *net.IPNet, name, shorthand string, value net.IPNet, usage string)

IPNetVarS is like IPNetVar, but accepts a shorthand letter that can be used after a single dash, alone.

func IPP

func IPP(name, shorthand string, value net.IP, usage string) *net.IP

IPP is like IP, but accepts a shorthand letter that can be used after a single dash.

func IPS added in v1.1.3

func IPS(name, shorthand string, value net.IP, usage string) *net.IP

IPS is like IP, but accepts a shorthand letter that can be used after a single dash, alone.

func IPSlice

func IPSlice(name string, value []net.IP, usage string) *[]net.IP

IPSlice defines a []net.IP flag with specified name, default value, and usage string. The return value is the address of a []net.IP variable that stores the value of the flag.

func IPSliceP

func IPSliceP(name, shorthand string, value []net.IP, usage string) *[]net.IP

IPSliceP is like IPSlice, but accepts a shorthand letter that can be used after a single dash.

func IPSliceS added in v1.1.3

func IPSliceS(name, shorthand string, value []net.IP, usage string) *[]net.IP

IPSliceS is like IPSlice, but accepts a shorthand letter that can be used after a single dash, alone.

func IPSliceVar

func IPSliceVar(p *[]net.IP, name string, value []net.IP, usage string)

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

func IPSliceVarP

func IPSliceVarP(p *[]net.IP, name, shorthand string, value []net.IP, usage string)

IPSliceVarP is like IPSliceVar, but accepts a shorthand letter that can be used after a single dash.

func IPSliceVarS added in v1.1.3

func IPSliceVarS(p *[]net.IP, name, shorthand string, value []net.IP, usage string)

IPSliceVarS is like IPSliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func IPVar

func IPVar(p *net.IP, name string, value net.IP, usage string)

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

func IPVarP

func IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string)

IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash.

func IPVarS added in v1.1.3

func IPVarS(p *net.IP, name, shorthand string, value net.IP, usage string)

IPVarS is like IPVar, but accepts a shorthand letter that can be used after a single dash, alone.

func Int

func Int(name string, value int, usage string) *int

Int defines an int flag with specified name, default value, and usage string. The return value is the address of an int variable that stores the value of the flag.

func Int16 added in v1.0.1

func Int16(name string, value int16, usage string) *int16

Int16 defines an int16 flag with specified name, default value, and usage string. The return value is the address of an int16 variable that stores the value of the flag.

func Int16P added in v1.0.1

func Int16P(name, shorthand string, value int16, usage string) *int16

Int16P is like Int16, but accepts a shorthand letter that can be used after a single dash.

func Int16S added in v1.1.3

func Int16S(name, shorthand string, value int16, usage string) *int16

Int16S is like Int16, but accepts a shorthand letter that can be used after a single dash, alone.

func Int16Slice added in v1.1.3

func Int16Slice(name string, value []int16, usage string) *[]int16

Int16Slice defines a []int16 flag with specified name, default value, and usage string. The return value is the address of a []int16 variable that stores the value of the flag.

func Int16SliceP added in v1.1.3

func Int16SliceP(name, shorthand string, value []int16, usage string) *[]int16

Int16SliceP is like Int16Slice, but accepts a shorthand letter that can be used after a single dash.

func Int16SliceS added in v1.1.3

func Int16SliceS(name, shorthand string, value []int16, usage string) *[]int16

Int16SliceS is like Int16Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func Int16SliceVar added in v1.1.3

func Int16SliceVar(p *[]int16, name string, value []int16, usage string)

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

func Int16SliceVarP added in v1.1.3

func Int16SliceVarP(p *[]int16, name, shorthand string, value []int16, usage string)

Int16SliceVarP is like Int16SliceVar, but accepts a shorthand letter that can be used after a single dash.

func Int16SliceVarS added in v1.1.3

func Int16SliceVarS(p *[]int16, name, shorthand string, value []int16, usage string)

Int16SliceVarS is like Int16SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func Int16Var added in v1.0.1

func Int16Var(p *int16, name string, value int16, usage string)

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

func Int16VarP added in v1.0.1

func Int16VarP(p *int16, name, shorthand string, value int16, usage string)

Int16VarP is like Int16Var, but accepts a shorthand letter that can be used after a single dash.

func Int16VarS added in v1.1.3

func Int16VarS(p *int16, name, shorthand string, value int16, usage string)

Int16VarS is like Int16Var, but accepts a shorthand letter that can be used after a single dash, alone.

func Int32

func Int32(name string, value int32, usage string) *int32

Int32 defines an int32 flag with specified name, default value, and usage string. The return value is the address of an int32 variable that stores the value of the flag.

func Int32P

func Int32P(name, shorthand string, value int32, usage string) *int32

Int32P is like Int32, but accepts a shorthand letter that can be used after a single dash.

func Int32S added in v1.1.3

func Int32S(name, shorthand string, value int32, usage string) *int32

Int32S is like Int32, but accepts a shorthand letter that can be used after a single dash, alone.

func Int32Slice added in v1.1.3

func Int32Slice(name string, value []int32, usage string) *[]int32

Int32Slice defines a []int32 flag with specified name, default value, and usage string. The return value is the address of a []int32 variable that stores the value of the flag.

func Int32SliceP added in v1.1.3

func Int32SliceP(name, shorthand string, value []int32, usage string) *[]int32

Int32SliceP is like Int32Slice, but accepts a shorthand letter that can be used after a single dash.

func Int32SliceS added in v1.1.3

func Int32SliceS(name, shorthand string, value []int32, usage string) *[]int32

Int32SliceS is like Int32Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func Int32SliceVar added in v1.1.3

func Int32SliceVar(p *[]int32, name string, value []int32, usage string)

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

func Int32SliceVarP added in v1.1.3

func Int32SliceVarP(p *[]int32, name, shorthand string, value []int32, usage string)

Int32SliceVarP is like Int32SliceVar, but accepts a shorthand letter that can be used after a single dash.

func Int32SliceVarS added in v1.1.3

func Int32SliceVarS(p *[]int32, name, shorthand string, value []int32, usage string)

Int32SliceVarS is like Int32SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func Int32Var

func Int32Var(p *int32, name string, value int32, usage string)

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

func Int32VarP

func Int32VarP(p *int32, name, shorthand string, value int32, usage string)

Int32VarP is like Int32Var, but accepts a shorthand letter that can be used after a single dash.

func Int32VarS added in v1.1.3

func Int32VarS(p *int32, name, shorthand string, value int32, usage string)

Int32VarS is like Int32Var, but accepts a shorthand letter that can be used after a single dash, alone.

func Int64

func Int64(name string, value int64, usage string) *int64

Int64 defines an int64 flag with specified name, default value, and usage string. The return value is the address of an int64 variable that stores the value of the flag.

func Int64P

func Int64P(name, shorthand string, value int64, usage string) *int64

Int64P is like Int64, but accepts a shorthand letter that can be used after a single dash.

func Int64S added in v1.1.3

func Int64S(name, shorthand string, value int64, usage string) *int64

Int64S is like Int64, but accepts a shorthand letter that can be used after a single dash, alone.

func Int64Slice added in v1.1.3

func Int64Slice(name string, value []int64, usage string) *[]int64

Int64Slice defines a []int64 flag with specified name, default value, and usage string. The return value is the address of a []int64 variable that stores the value of the flag.

func Int64SliceP added in v1.1.3

func Int64SliceP(name, shorthand string, value []int64, usage string) *[]int64

Int64SliceP is like Int64Slice, but accepts a shorthand letter that can be used after a single dash.

func Int64SliceS added in v1.1.3

func Int64SliceS(name, shorthand string, value []int64, usage string) *[]int64

Int64SliceS is like Int64Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func Int64SliceVar added in v1.1.3

func Int64SliceVar(p *[]int64, name string, value []int64, usage string)

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

func Int64SliceVarP added in v1.1.3

func Int64SliceVarP(p *[]int64, name, shorthand string, value []int64, usage string)

Int64SliceVarP is like Int64SliceVar, but accepts a shorthand letter that can be used after a single dash.

func Int64SliceVarS added in v1.1.3

func Int64SliceVarS(p *[]int64, name, shorthand string, value []int64, usage string)

Int64SliceVarS is like Int64SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func Int64Var

func Int64Var(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 Int64VarP

func Int64VarP(p *int64, name, shorthand string, value int64, usage string)

Int64VarP is like Int64Var, but accepts a shorthand letter that can be used after a single dash.

func Int64VarS added in v1.1.3

func Int64VarS(p *int64, name, shorthand string, value int64, usage string)

Int64VarS is like Int64Var, but accepts a shorthand letter that can be used after a single dash, alone.

func Int8

func Int8(name string, value int8, usage string) *int8

Int8 defines an int8 flag with specified name, default value, and usage string. The return value is the address of an int8 variable that stores the value of the flag.

func Int8P

func Int8P(name, shorthand string, value int8, usage string) *int8

Int8P is like Int8, but accepts a shorthand letter that can be used after a single dash.

func Int8S added in v1.1.3

func Int8S(name, shorthand string, value int8, usage string) *int8

Int8S is like Int8, but accepts a shorthand letter that can be used after a single dash, alone.

func Int8Slice added in v1.1.3

func Int8Slice(name string, value []int8, usage string) *[]int8

Int8Slice defines a []int8 flag with specified name, default value, and usage string. The return value is the address of a []int8 variable that stores the value of the flag.

func Int8SliceP added in v1.1.3

func Int8SliceP(name, shorthand string, value []int8, usage string) *[]int8

Int8SliceP is like Int8Slice, but accepts a shorthand letter that can be used after a single dash.

func Int8SliceS added in v1.1.3

func Int8SliceS(name, shorthand string, value []int8, usage string) *[]int8

Int8SliceS is like Int8Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func Int8SliceVar added in v1.1.3

func Int8SliceVar(p *[]int8, name string, value []int8, usage string)

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

func Int8SliceVarP added in v1.1.3

func Int8SliceVarP(p *[]int8, name, shorthand string, value []int8, usage string)

Int8SliceVarP is like Int8SliceVar, but accepts a shorthand letter that can be used after a single dash.

func Int8SliceVarS added in v1.1.3

func Int8SliceVarS(p *[]int8, name, shorthand string, value []int8, usage string)

Int8SliceVarS is like Int8SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func Int8Var

func Int8Var(p *int8, name string, value int8, usage string)

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

func Int8VarP

func Int8VarP(p *int8, name, shorthand string, value int8, usage string)

Int8VarP is like Int8Var, but accepts a shorthand letter that can be used after a single dash.

func Int8VarS added in v1.1.3

func Int8VarS(p *int8, name, shorthand string, value int8, usage string)

Int8VarS is like Int8Var, but accepts a shorthand letter that can be used after a single dash, alone.

func IntP

func IntP(name, shorthand string, value int, usage string) *int

IntP is like Int, but accepts a shorthand letter that can be used after a single dash.

func IntS added in v1.1.3

func IntS(name, shorthand string, value int, usage string) *int

IntS is like Int, but accepts a shorthand letter that can be used after a single dash, alone.

func IntSlice

func IntSlice(name string, value []int, usage string) *[]int

IntSlice defines a []int flag with specified name, default value, and usage string. The return value is the address of a []int variable that stores the value of the flag.

func IntSliceP

func IntSliceP(name, shorthand string, value []int, usage string) *[]int

IntSliceP is like IntSlice, but accepts a shorthand letter that can be used after a single dash.

func IntSliceS added in v1.1.3

func IntSliceS(name, shorthand string, value []int, usage string) *[]int

IntSliceS is like IntSlice, but accepts a shorthand letter that can be used after a single dash, alone.

func IntSliceVar

func IntSliceVar(p *[]int, name string, value []int, usage string)

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

func IntSliceVarP

func IntSliceVarP(p *[]int, name, shorthand string, value []int, usage string)

IntSliceVarP is like IntSliceVar, but accepts a shorthand letter that can be used after a single dash.

func IntSliceVarS added in v1.1.3

func IntSliceVarS(p *[]int, name, shorthand string, value []int, usage string)

IntSliceVarS is like IntSliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func IntVar

func IntVar(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 IntVarP

func IntVarP(p *int, name, shorthand string, value int, usage string)

IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash.

func IntVarS added in v1.1.3

func IntVarS(p *int, name, shorthand string, value int, usage string)

IntVarS is like IntVar, but accepts a shorthand letter that can be used after a single dash, alone.

func NArg

func NArg() int

NArg is the number of arguments remaining after flags have been processed.

func NFlag

func NFlag() int

NFlag returns the number of command-line flags that have been set.

func Parse

func Parse()

Parse parses the command-line flags from os.Args[1:]. Must be called after all flags are defined and before flags are accessed by the program.

func ParseAll

func ParseAll(fn func(flag *Flag, value string) error)

ParseAll parses the command-line flags from os.Args[1:] and called fn for each. The arguments for fn are flag and value. Must be called after all flags are defined and before flags are accessed by the program.

func ParseIPv4Mask

func ParseIPv4Mask(s string) net.IPMask

ParseIPv4Mask written in IP form (e.g. 255.255.255.0). This function should really belong to the net package.

func Parsed

func Parsed() bool

Parsed returns true if the command-line flags have been parsed.

func PrintDefaults

func PrintDefaults()

PrintDefaults prints, to standard error unless configured otherwise, a usage message showing the default settings of all defined command-line flags. For an integer valued flag x, the default output has the form

-x int
	usage-message-for-x (default 7)

The usage message will appear on a separate line for anything but a bool flag with a one-byte name. For bool flags, the type is omitted and if the flag name is one byte the usage message appears on the same line. The parenthetical default is omitted if the default is the zero value for the type. The listed type, here int, can be changed by placing a back-quoted name in the flag's usage string; the first such item in the message is taken to be a parameter name to show in the message and the back quotes are stripped from the message when displayed. For instance, given

flag.String("I", "", "search `directory` for include files")

the output will be

-I directory
	search directory for include files.

To change the destination for flag messages, call CommandLine.SetOutput.

func Set

func Set(name, value string) error

Set sets the value of the named command-line flag.

func SetInterspersed

func SetInterspersed(interspersed bool)

SetInterspersed sets whether to support interspersed option/non-option arguments.

func String

func String(name string, value string, usage string) *string

String defines a string flag with specified name, default value, and usage string. The return value is the address of a string variable that stores the value of the flag.

func StringArray

func StringArray(name string, value []string, usage string) *[]string

StringArray defines a string flag with specified name, default value, and usage string. The return value is the address of a []string variable that stores the value of the flag. The value of each argument will not try to be separated by comma. Use a StringSlice for that.

func StringArrayP

func StringArrayP(name, shorthand string, value []string, usage string) *[]string

StringArrayP is like StringArray, but accepts a shorthand letter that can be used after a single dash.

func StringArrayS added in v1.1.3

func StringArrayS(name, shorthand string, value []string, usage string) *[]string

StringArrayS is like StringArray, but accepts a shorthand letter that can be used after a single dash, alone.

func StringArrayVar

func StringArrayVar(p *[]string, name string, value []string, usage string)

StringArrayVar 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. The value of each argument will not try to be separated by comma. Use a StringSlice for that.

func StringArrayVarP

func StringArrayVarP(p *[]string, name, shorthand string, value []string, usage string)

StringArrayVarP is like StringArrayVar, but accepts a shorthand letter that can be used after a single dash.

func StringArrayVarS added in v1.1.3

func StringArrayVarS(p *[]string, name, shorthand string, value []string, usage string)

StringArrayVarS is like StringArrayVar, but accepts a shorthand letter that can be used after a single dash, alone.

func StringP

func StringP(name, shorthand string, value string, usage string) *string

StringP is like String, but accepts a shorthand letter that can be used after a single dash.

func StringS added in v1.1.3

func StringS(name, shorthand string, value string, usage string) *string

StringS is like String, but accepts a shorthand letter that can be used after a single dash, alone.

func StringSlice

func StringSlice(name string, value []string, usage string) *[]string

StringSlice defines a string flag with specified name, default value, and usage string. The return value is the address of a []string variable that stores the value of the flag. Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly. For example:

--ss="v1,v2" --ss="v3"

will result in

[]string{"v1", "v2", "v3"}

func StringSliceP

func StringSliceP(name, shorthand string, value []string, usage string) *[]string

StringSliceP is like StringSlice, but accepts a shorthand letter that can be used after a single dash.

func StringSliceS added in v1.1.3

func StringSliceS(name, shorthand string, value []string, usage string) *[]string

StringSliceS is like StringSlice, but accepts a shorthand letter that can be used after a single dash, alone.

func StringSliceVar

func StringSliceVar(p *[]string, name string, value []string, usage string)

StringSliceVar 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. Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly. For example:

--ss="v1,v2" --ss="v3"

will result in

[]string{"v1", "v2", "v3"}

func StringSliceVarP

func StringSliceVarP(p *[]string, name, shorthand string, value []string, usage string)

StringSliceVarP is like StringSliceVar, but accepts a shorthand letter that can be used after a single dash.

func StringSliceVarS added in v1.1.3

func StringSliceVarS(p *[]string, name, shorthand string, value []string, usage string)

StringSliceVarS is like StringSliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func StringToInt added in v1.0.3

func StringToInt(name string, value map[string]int, usage string) *map[string]int

StringToInt defines a string flag with specified name, default value, and usage string. The return value is the address of a map[string]int variable that stores the value of the flag. The value of each argument will not try to be separated by comma

func StringToInt64 added in v1.1.3

func StringToInt64(name string, value map[string]int64, usage string) *map[string]int64

StringToInt64 defines a string flag with specified name, default value, and usage string. The return value is the address of a map[string]int64 variable that stores the value of the flag. The value of each argument will not try to be separated by comma

func StringToInt64P added in v1.1.3

func StringToInt64P(name, shorthand string, value map[string]int64, usage string) *map[string]int64

StringToInt64P is like StringToInt64, but accepts a shorthand letter that can be used after a single dash.

func StringToInt64S added in v1.1.3

func StringToInt64S(name, shorthand string, value map[string]int64, usage string) *map[string]int64

StringToInt64S is like StringToInt64, but accepts a shorthand letter that can be used after a single dash, alone.

func StringToInt64Var added in v1.1.3

func StringToInt64Var(p *map[string]int64, name string, value map[string]int64, usage string)

StringToInt64Var defines a string flag with specified name, default value, and usage string. The argument p point64s to a map[string]int64 variable in which to store the value of the flag. The value of each argument will not try to be separated by comma

func StringToInt64VarP added in v1.1.3

func StringToInt64VarP(p *map[string]int64, name, shorthand string, value map[string]int64, usage string)

StringToInt64VarP is like StringToInt64Var, but accepts a shorthand letter that can be used after a single dash.

func StringToInt64VarS added in v1.1.3

func StringToInt64VarS(p *map[string]int64, name, shorthand string, value map[string]int64, usage string)

StringToInt64VarS is like StringToInt64Var, but accepts a shorthand letter that can be used after a single dash, alone.

func StringToIntP added in v1.0.3

func StringToIntP(name, shorthand string, value map[string]int, usage string) *map[string]int

StringToIntP is like StringToInt, but accepts a shorthand letter that can be used after a single dash.

func StringToIntS added in v1.1.3

func StringToIntS(name, shorthand string, value map[string]int, usage string) *map[string]int

StringToIntS is like StringToInt, but accepts a shorthand letter that can be used after a single dash, alone.

func StringToIntVar added in v1.0.3

func StringToIntVar(p *map[string]int, name string, value map[string]int, usage string)

StringToIntVar defines a string flag with specified name, default value, and usage string. The argument p points to a map[string]int variable in which to store the value of the flag. The value of each argument will not try to be separated by comma

func StringToIntVarP added in v1.0.3

func StringToIntVarP(p *map[string]int, name, shorthand string, value map[string]int, usage string)

StringToIntVarP is like StringToIntVar, but accepts a shorthand letter that can be used after a single dash.

func StringToIntVarS added in v1.1.3

func StringToIntVarS(p *map[string]int, name, shorthand string, value map[string]int, usage string)

StringToIntVarS is like StringToIntVar, but accepts a shorthand letter that can be used after a single dash, alone.

func StringToString added in v1.0.3

func StringToString(name string, value map[string]string, usage string) *map[string]string

StringToString defines a string flag with specified name, default value, and usage string. The return value is the address of a map[string]string variable that stores the value of the flag. The value of each argument will not try to be separated by comma

func StringToStringP added in v1.0.3

func StringToStringP(name, shorthand string, value map[string]string, usage string) *map[string]string

StringToStringP is like StringToString, but accepts a shorthand letter that can be used after a single dash.

func StringToStringS added in v1.1.3

func StringToStringS(name, shorthand string, value map[string]string, usage string) *map[string]string

StringToStringS is like StringToString, but accepts a shorthand letter that can be used after a single dash, alone.

func StringToStringVar added in v1.0.3

func StringToStringVar(p *map[string]string, name string, value map[string]string, usage string)

StringToStringVar defines a string flag with specified name, default value, and usage string. The argument p points to a map[string]string variable in which to store the value of the flag. The value of each argument will not try to be separated by comma

func StringToStringVarP added in v1.0.3

func StringToStringVarP(p *map[string]string, name, shorthand string, value map[string]string, usage string)

StringToStringVarP is like StringToStringVar, but accepts a shorthand letter that can be used after a single dash.

func StringToStringVarS added in v1.1.3

func StringToStringVarS(p *map[string]string, name, shorthand string, value map[string]string, usage string)

StringToStringVarS is like StringToStringVar, but accepts a shorthand letter that can be used after a single dash, alone.

func StringVar

func StringVar(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 StringVarP

func StringVarP(p *string, name, shorthand string, value string, usage string)

StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash.

func StringVarS added in v1.1.3

func StringVarS(p *string, name, shorthand string, value string, usage string)

StringVarS is like StringVar, but accepts a shorthand letter that can be used after a single dash, alone.

func Uint

func Uint(name string, value uint, usage string) *uint

Uint defines a uint flag with specified name, default value, and usage string. The return value is the address of a uint variable that stores the value of the flag.

func Uint16

func Uint16(name string, value uint16, usage string) *uint16

Uint16 defines a uint flag with specified name, default value, and usage string. The return value is the address of a uint variable that stores the value of the flag.

func Uint16P

func Uint16P(name, shorthand string, value uint16, usage string) *uint16

Uint16P is like Uint16, but accepts a shorthand letter that can be used after a single dash.

func Uint16S added in v1.1.3

func Uint16S(name, shorthand string, value uint16, usage string) *uint16

Uint16S is like Uint16, but accepts a shorthand letter that can be used after a single dash, alone.

func Uint16Slice added in v1.1.3

func Uint16Slice(name string, value []uint16, usage string) *[]uint16

Uint16Slice defines a []uint16 flag with specified name, default value, and usage string. The return value is the address of a []uint16 variable that stores the value of the flag.

func Uint16SliceP added in v1.1.3

func Uint16SliceP(name, shorthand string, value []uint16, usage string) *[]uint16

Uint16SliceP is like Uint16Slice, but accepts a shorthand letter that can be used after a single dash.

func Uint16SliceS added in v1.1.3

func Uint16SliceS(name, shorthand string, value []uint16, usage string) *[]uint16

Uint16SliceS is like Uint16Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func Uint16SliceVar added in v1.1.3

func Uint16SliceVar(p *[]uint16, name string, value []uint16, usage string)

Uint16SliceVar defines a uint16[] flag with specified name, default value, and usage string. The argument p pouints to a uint16[] variable in which to store the value of the flag.

func Uint16SliceVarP added in v1.1.3

func Uint16SliceVarP(p *[]uint16, name, shorthand string, value []uint16, usage string)

Uint16SliceVarP is like Uint16SliceVar, but accepts a shorthand letter that can be used after a single dash.

func Uint16SliceVarS added in v1.1.3

func Uint16SliceVarS(p *[]uint16, name, shorthand string, value []uint16, usage string)

Uint16SliceVarS is like Uint16SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func Uint16Var

func Uint16Var(p *uint16, name string, value uint16, usage string)

Uint16Var 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 Uint16VarP

func Uint16VarP(p *uint16, name, shorthand string, value uint16, usage string)

Uint16VarP is like Uint16Var, but accepts a shorthand letter that can be used after a single dash.

func Uint16VarS added in v1.1.3

func Uint16VarS(p *uint16, name, shorthand string, value uint16, usage string)

Uint16VarS is like Uint16Var, but accepts a shorthand letter that can be used after a single dash, alone.

func Uint32

func Uint32(name string, value uint32, usage string) *uint32

Uint32 defines a uint32 flag with specified name, default value, and usage string. The return value is the address of a uint32 variable that stores the value of the flag.

func Uint32P

func Uint32P(name, shorthand string, value uint32, usage string) *uint32

Uint32P is like Uint32, but accepts a shorthand letter that can be used after a single dash.

func Uint32S added in v1.1.3

func Uint32S(name, shorthand string, value uint32, usage string) *uint32

Uint32S is like Uint32, but accepts a shorthand letter that can be used after a single dash, alone.

func Uint32Slice added in v1.1.3

func Uint32Slice(name string, value []uint32, usage string) *[]uint32

Uint32Slice defines a []uint32 flag with specified name, default value, and usage string. The return value is the address of a []uint32 variable that stores the value of the flag.

func Uint32SliceP added in v1.1.3

func Uint32SliceP(name, shorthand string, value []uint32, usage string) *[]uint32

Uint32SliceP is like Uint32Slice, but accepts a shorthand letter that can be used after a single dash.

func Uint32SliceS added in v1.1.3

func Uint32SliceS(name, shorthand string, value []uint32, usage string) *[]uint32

Uint32SliceS is like Uint32Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func Uint32SliceVar added in v1.1.3

func Uint32SliceVar(p *[]uint32, name string, value []uint32, usage string)

Uint32SliceVar defines a uint32[] flag with specified name, default value, and usage string. The argument p pouints to a uint32[] variable in which to store the value of the flag.

func Uint32SliceVarP added in v1.1.3

func Uint32SliceVarP(p *[]uint32, name, shorthand string, value []uint32, usage string)

Uint32SliceVarP is like Uint32SliceVar, but accepts a shorthand letter that can be used after a single dash.

func Uint32SliceVarS added in v1.1.3

func Uint32SliceVarS(p *[]uint32, name, shorthand string, value []uint32, usage string)

Uint32SliceVarS is like Uint32SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func Uint32Var

func Uint32Var(p *uint32, name string, value uint32, usage string)

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

func Uint32VarP

func Uint32VarP(p *uint32, name, shorthand string, value uint32, usage string)

Uint32VarP is like Uint32Var, but accepts a shorthand letter that can be used after a single dash.

func Uint32VarS added in v1.1.3

func Uint32VarS(p *uint32, name, shorthand string, value uint32, usage string)

Uint32VarS is like Uint32Var, but accepts a shorthand letter that can be used after a single dash, alone.

func Uint64

func Uint64(name string, value uint64, usage string) *uint64

Uint64 defines a uint64 flag with specified name, default value, and usage string. The return value is the address of a uint64 variable that stores the value of the flag.

func Uint64P

func Uint64P(name, shorthand string, value uint64, usage string) *uint64

Uint64P is like Uint64, but accepts a shorthand letter that can be used after a single dash.

func Uint64S added in v1.1.3

func Uint64S(name, shorthand string, value uint64, usage string) *uint64

Uint64S is like Uint64, but accepts a shorthand letter that can be used after a single dash, alone.

func Uint64Slice added in v1.1.3

func Uint64Slice(name string, value []uint64, usage string) *[]uint64

Uint64Slice defines a []uint64 flag with specified name, default value, and usage string. The return value is the address of a []uint64 variable that stores the value of the flag.

func Uint64SliceP added in v1.1.3

func Uint64SliceP(name, shorthand string, value []uint64, usage string) *[]uint64

Uint64SliceP is like Uint64Slice, but accepts a shorthand letter that can be used after a single dash.

func Uint64SliceS added in v1.1.3

func Uint64SliceS(name, shorthand string, value []uint64, usage string) *[]uint64

Uint64SliceS is like Uint64Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func Uint64SliceVar added in v1.1.3

func Uint64SliceVar(p *[]uint64, name string, value []uint64, usage string)

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

func Uint64SliceVarP added in v1.1.3

func Uint64SliceVarP(p *[]uint64, name, shorthand string, value []uint64, usage string)

Uint64SliceVarP is like Uint64SliceVar, but accepts a shorthand letter that can be used after a single dash.

func Uint64SliceVarS added in v1.1.3

func Uint64SliceVarS(p *[]uint64, name, shorthand string, value []uint64, usage string)

Uint64SliceVarS is like Uint64SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func Uint64Var

func Uint64Var(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 Uint64VarP

func Uint64VarP(p *uint64, name, shorthand string, value uint64, usage string)

Uint64VarP is like Uint64Var, but accepts a shorthand letter that can be used after a single dash.

func Uint64VarS added in v1.1.3

func Uint64VarS(p *uint64, name, shorthand string, value uint64, usage string)

Uint64VarS is like Uint64Var, but accepts a shorthand letter that can be used after a single dash, alone.

func Uint8

func Uint8(name string, value uint8, usage string) *uint8

Uint8 defines a uint8 flag with specified name, default value, and usage string. The return value is the address of a uint8 variable that stores the value of the flag.

func Uint8P

func Uint8P(name, shorthand string, value uint8, usage string) *uint8

Uint8P is like Uint8, but accepts a shorthand letter that can be used after a single dash.

func Uint8S added in v1.1.3

func Uint8S(name, shorthand string, value uint8, usage string) *uint8

Uint8S is like Uint8, but accepts a shorthand letter that can be used after a single dash, alone.

func Uint8Slice added in v1.1.3

func Uint8Slice(name string, value []uint8, usage string) *[]uint8

Uint8Slice defines a []uint8 flag with specified name, default value, and usage string. The return value is the address of a []uint8 variable that stores the value of the flag.

func Uint8SliceP added in v1.1.3

func Uint8SliceP(name, shorthand string, value []uint8, usage string) *[]uint8

Uint8SliceP is like Uint8Slice, but accepts a shorthand letter that can be used after a single dash.

func Uint8SliceS added in v1.1.3

func Uint8SliceS(name, shorthand string, value []uint8, usage string) *[]uint8

Uint8SliceS is like Uint8Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func Uint8SliceVar added in v1.1.3

func Uint8SliceVar(p *[]uint8, name string, value []uint8, usage string)

Uint8SliceVar defines a uint8[] flag with specified name, default value, and usage string. The argument p pouints to a uint8[] variable in which to store the value of the flag.

func Uint8SliceVarP added in v1.1.3

func Uint8SliceVarP(p *[]uint8, name, shorthand string, value []uint8, usage string)

Uint8SliceVarP is like Uint8SliceVar, but accepts a shorthand letter that can be used after a single dash.

func Uint8SliceVarS added in v1.1.3

func Uint8SliceVarS(p *[]uint8, name, shorthand string, value []uint8, usage string)

Uint8SliceVarS is like Uint8SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func Uint8Var

func Uint8Var(p *uint8, name string, value uint8, usage string)

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

func Uint8VarP

func Uint8VarP(p *uint8, name, shorthand string, value uint8, usage string)

Uint8VarP is like Uint8Var, but accepts a shorthand letter that can be used after a single dash.

func Uint8VarS added in v1.1.3

func Uint8VarS(p *uint8, name, shorthand string, value uint8, usage string)

Uint8VarS is like Uint8Var, but accepts a shorthand letter that can be used after a single dash, alone.

func UintP

func UintP(name, shorthand string, value uint, usage string) *uint

UintP is like Uint, but accepts a shorthand letter that can be used after a single dash.

func UintS added in v1.1.3

func UintS(name, shorthand string, value uint, usage string) *uint

UintS is like Uint, but accepts a shorthand letter that can be used after a single dash, alone.

func UintSlice

func UintSlice(name string, value []uint, usage string) *[]uint

UintSlice defines a []uint flag with specified name, default value, and usage string. The return value is the address of a []uint variable that stores the value of the flag.

func UintSliceP

func UintSliceP(name, shorthand string, value []uint, usage string) *[]uint

UintSliceP is like UintSlice, but accepts a shorthand letter that can be used after a single dash.

func UintSliceS added in v1.1.3

func UintSliceS(name, shorthand string, value []uint, usage string) *[]uint

UintSliceS is like UintSlice, but accepts a shorthand letter that can be used after a single dash, alone.

func UintSliceVar

func UintSliceVar(p *[]uint, name string, value []uint, usage string)

UintSliceVar 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 UintSliceVarP

func UintSliceVarP(p *[]uint, name, shorthand string, value []uint, usage string)

UintSliceVarP is like the UintSliceVar, but accepts a shorthand letter that can be used after a single dash.

func UintSliceVarS added in v1.1.3

func UintSliceVarS(p *[]uint, name, shorthand string, value []uint, usage string)

UintSliceVarS is like the UintSliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func UintVar

func UintVar(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 UintVarP

func UintVarP(p *uint, name, shorthand string, value uint, usage string)

UintVarP is like UintVar, but accepts a shorthand letter that can be used after a single dash.

func UintVarS added in v1.1.3

func UintVarS(p *uint, name, shorthand string, value uint, usage string)

UintVarS is like UintVar, but accepts a shorthand letter that can be used after a single dash, alone.

func UnquoteUsage

func UnquoteUsage(flag *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.

func Var

func Var(value 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 Value, which typically holds a user-defined implementation of Value. For instance, the caller could create a flag that turns a comma-separated string into a slice of strings by giving the slice the methods of Value; in particular, Set would decompose the comma-separated string into the slice.

func VarP

func VarP(value Value, name, shorthand, usage string)

VarP is like Var, but accepts a shorthand letter that can be used after a single dash.

func VarS added in v1.1.3

func VarS(value Value, name, shorthand, usage string)

VarS is like Var, but accepts a shorthand letter that can be used after a single dash, alone.

func Visit

func Visit(fn func(*Flag))

Visit visits the command-line flags in lexicographical order or in primordial order if f.SortFlags is false, calling fn for each. It visits only those flags that have been set.

func VisitAll

func VisitAll(fn func(*Flag))

VisitAll visits the command-line flags in lexicographical order or in primordial order if f.SortFlags is false, calling fn for each. It visits all flags, even those not set.

Types

type ErrorHandling

type ErrorHandling int

ErrorHandling defines how to handle flag parsing errors.

const (
	// ContinueOnError will return an err from Parse() if an error is found
	ContinueOnError ErrorHandling = iota
	// ExitOnError will call os.Exit(2) if an error is found when parsing
	ExitOnError
	// PanicOnError will panic() if an error is found when parsing flags
	PanicOnError
)

type Flag

type Flag struct {
	Name                string              // name as it appears on command line
	Shorthand           string              // one-letter abbreviated flag
	ShorthandOnly       bool                // If the user set only the shorthand
	Usage               string              // help message
	CustomUsageType     string              // flag type displayed in the help message
	DisableUnquoteUsage bool                // toggle unquoting and extraction of type from usage
	DisablePrintDefault bool                // toggle printing of the default value in usage message
	Value               Value               // value as set
	DefValue            string              // default value (as text); for usage message
	Changed             bool                // If the user set the value (or if left to default)
	NoOptDefVal         string              // default value (as text); if the flag is on the command line without any options
	Deprecated          string              // If this flag is deprecated, this string is the new or now thing to use
	Hidden              bool                // used by cobra.Command to allow flags to be hidden from help/usage text
	ShorthandDeprecated string              // If the shorthand of this flag is deprecated, this string is the new or now thing to use
	Annotations         map[string][]string // used by cobra.Command bash autocomple code
}

A Flag represents the state of a flag.

func GetAllFlags added in v1.1.3

func GetAllFlags() []*Flag

GetAllFlags return the flags in lexicographical order or in primordial order if f.SortFlags is false.

func GetFlags added in v1.1.3

func GetFlags() []*Flag

GetFlags return the flags in lexicographical order or in primordial order if f.SortFlags is false.

func Lookup

func Lookup(name string) *Flag

Lookup returns the Flag structure of the named command-line flag, returning nil if none exists.

func PFlagFromGoFlag

func PFlagFromGoFlag(goflag *goflag.Flag) *Flag

PFlagFromGoFlag will return a *pflag.Flag given a *flag.Flag If the *flag.Flag.Name was a single character (ex: `v`) it will be accessible with both `-v` and `--v` in flags. If the golang flag was more than a single character (ex: `verbose`) it will only be accessible via `--verbose`

func ShorthandLookup

func ShorthandLookup(name string) *Flag

ShorthandLookup returns the Flag structure of the short handed flag, returning nil if none exists.

Example
name := "verbose"
short := name[:1]

BoolP(name, short, false, "verbose output")

// len(short) must be == 1
flag := ShorthandLookup(short)

fmt.Println(flag.Name)
Output:

type FlagSet

type FlagSet struct {
	// Usage is the function called when an error occurs while parsing flags.
	// The field is a function (not a method) that may be changed to point to
	// a custom error handler.
	Usage func()

	// SortFlags is used to indicate, if user wants to have sorted flags in
	// help/usage messages.
	SortFlags bool

	// ParseErrorsWhitelist is used to configure a whitelist of errors
	ParseErrorsWhitelist ParseErrorsWhitelist

	// DisableBuiltinHelp toggles the built-in convention of handling -h and --help
	DisableBuiltinHelp bool
	// contains filtered or unexported fields
}

A FlagSet represents a set of defined flags.

func NewFlagSet

func NewFlagSet(name string, errorHandling ErrorHandling) *FlagSet

NewFlagSet returns a new, empty flag set with the specified name, error handling property and SortFlags set to true.

func (*FlagSet) AddFlag

func (f *FlagSet) AddFlag(flag *Flag)

AddFlag will add the flag to the FlagSet

func (*FlagSet) AddFlagSet

func (f *FlagSet) AddFlagSet(newSet *FlagSet)

AddFlagSet adds one FlagSet to another. If a flag is already present in f the flag from newSet will be ignored.

func (*FlagSet) AddGoFlag

func (f *FlagSet) AddGoFlag(goflag *goflag.Flag)

AddGoFlag will add the given *flag.Flag to the pflag.FlagSet

func (*FlagSet) AddGoFlagSet

func (f *FlagSet) AddGoFlagSet(newSet *goflag.FlagSet)

AddGoFlagSet will add the given *flag.FlagSet to the pflag.FlagSet

func (*FlagSet) Arg

func (f *FlagSet) Arg(i int) string

Arg returns the i'th argument. Arg(0) is the first remaining argument after flags have been processed.

func (*FlagSet) Args

func (f *FlagSet) Args() []string

Args returns the non-flag arguments.

func (*FlagSet) ArgsLenAtDash

func (f *FlagSet) ArgsLenAtDash() int

ArgsLenAtDash will return the length of f.Args at the moment when a -- was found during arg parsing. This allows your program to know which args were before the -- and which came after.

func (*FlagSet) Bool

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

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

func (*FlagSet) BoolP

func (f *FlagSet) BoolP(name, shorthand string, value bool, usage string) *bool

BoolP is like Bool, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) BoolS added in v1.1.3

func (f *FlagSet) BoolS(name string, shorthand string, value bool, usage string) *bool

BoolS is like Bool, but accepts a shorthand letter to be used after a single dash, alone.

func (*FlagSet) BoolSlice

func (f *FlagSet) BoolSlice(name string, value []bool, usage string) *[]bool

BoolSlice defines a []bool flag with specified name, default value, and usage string. The return value is the address of a []bool variable that stores the value of the flag.

func (*FlagSet) BoolSliceP

func (f *FlagSet) BoolSliceP(name, shorthand string, value []bool, usage string) *[]bool

BoolSliceP is like BoolSlice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) BoolSliceS added in v1.1.3

func (f *FlagSet) BoolSliceS(name string, shorthand string, value []bool, usage string) *[]bool

BoolSliceS is like BoolSlice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) BoolSliceVar

func (f *FlagSet) BoolSliceVar(p *[]bool, name string, value []bool, usage string)

BoolSliceVar defines a boolSlice 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) BoolSliceVarP

func (f *FlagSet) BoolSliceVarP(p *[]bool, name, shorthand string, value []bool, usage string)

BoolSliceVarP is like BoolSliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) BoolSliceVarS added in v1.1.3

func (f *FlagSet) BoolSliceVarS(p *[]bool, name string, shorthand string, value []bool, usage string)

BoolSliceVarS is like BoolSliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) BoolVar

func (f *FlagSet) BoolVar(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) BoolVarP

func (f *FlagSet) BoolVarP(p *bool, name, shorthand string, value bool, usage string)

BoolVarP is like BoolVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) BoolVarS added in v1.1.3

func (f *FlagSet) BoolVarS(p *bool, name string, shorthand string, value bool, usage string)

BoolVarS is like BoolVar, but accepts a shorthand letter to be used after a single dash, alone.

func (*FlagSet) BytesBase64 added in v1.0.2

func (f *FlagSet) BytesBase64(name string, value []byte, usage string) *[]byte

BytesBase64 defines an []byte flag with specified name, default value, and usage string. The return value is the address of an []byte variable that stores the value of the flag.

func (*FlagSet) BytesBase64P added in v1.0.2

func (f *FlagSet) BytesBase64P(name, shorthand string, value []byte, usage string) *[]byte

BytesBase64P is like BytesBase64, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) BytesBase64S added in v1.1.3

func (f *FlagSet) BytesBase64S(name, shorthand string, value []byte, usage string) *[]byte

BytesBase64S is like BytesBase64, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) BytesBase64Var added in v1.0.2

func (f *FlagSet) BytesBase64Var(p *[]byte, name string, value []byte, usage string)

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

func (*FlagSet) BytesBase64VarP added in v1.0.2

func (f *FlagSet) BytesBase64VarP(p *[]byte, name, shorthand string, value []byte, usage string)

BytesBase64VarP is like BytesBase64Var, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) BytesBase64VarS added in v1.1.3

func (f *FlagSet) BytesBase64VarS(p *[]byte, name, shorthand string, value []byte, usage string)

BytesBase64VarS is like BytesBase64Var, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) BytesHex added in v1.0.1

func (f *FlagSet) BytesHex(name string, value []byte, usage string) *[]byte

BytesHex defines an []byte flag with specified name, default value, and usage string. The return value is the address of an []byte variable that stores the value of the flag.

func (*FlagSet) BytesHexP added in v1.0.1

func (f *FlagSet) BytesHexP(name, shorthand string, value []byte, usage string) *[]byte

BytesHexP is like BytesHex, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) BytesHexS added in v1.1.3

func (f *FlagSet) BytesHexS(name, shorthand string, value []byte, usage string) *[]byte

BytesHexS is like BytesHexP, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) BytesHexVar added in v1.0.1

func (f *FlagSet) BytesHexVar(p *[]byte, name string, value []byte, usage string)

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

func (*FlagSet) BytesHexVarP added in v1.0.1

func (f *FlagSet) BytesHexVarP(p *[]byte, name, shorthand string, value []byte, usage string)

BytesHexVarP is like BytesHexVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) BytesHexVarS added in v1.1.3

func (f *FlagSet) BytesHexVarS(p *[]byte, name, shorthand string, value []byte, usage string)

BytesHexVarS is like BytesHexVarP, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Changed

func (f *FlagSet) Changed(name string) bool

Changed returns true if the flag was explicitly set during Parse() and false otherwise

func (*FlagSet) Complex128 added in v1.1.3

func (f *FlagSet) Complex128(name string, value complex128, usage string) *complex128

Complex128 defines a complex128 flag with specified name, default value, and usage string. The return value is the address of a complex128 variable that stores the value of the flag.

func (*FlagSet) Complex128P added in v1.1.3

func (f *FlagSet) Complex128P(name, shorthand string, value complex128, usage string) *complex128

Complex128P is like Complex128, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Complex128S added in v1.1.3

func (f *FlagSet) Complex128S(name, shorthand string, value complex128, usage string) *complex128

Complex128S is like Complex128, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Complex128Slice added in v1.1.3

func (f *FlagSet) Complex128Slice(name string, value []complex128, usage string) *[]complex128

Complex128Slice defines a []complex128 flag with specified name, default value, and usage string. The return value is the address of a []complex128 variable that stores the value of the flag.

func (*FlagSet) Complex128SliceP added in v1.1.3

func (f *FlagSet) Complex128SliceP(name, shorthand string, value []complex128, usage string) *[]complex128

Complex128SliceP is like Complex128Slice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Complex128SliceS added in v1.1.3

func (f *FlagSet) Complex128SliceS(name, shorthand string, value []complex128, usage string) *[]complex128

Complex128SliceS is like Complex128Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Complex128SliceVar added in v1.1.3

func (f *FlagSet) Complex128SliceVar(p *[]complex128, name string, value []complex128, usage string)

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

func (*FlagSet) Complex128SliceVarP added in v1.1.3

func (f *FlagSet) Complex128SliceVarP(p *[]complex128, name, shorthand string, value []complex128, usage string)

Complex128SliceVarP is like Complex128SliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Complex128SliceVarS added in v1.1.3

func (f *FlagSet) Complex128SliceVarS(p *[]complex128, name, shorthand string, value []complex128, usage string)

Complex128SliceVarS is like Complex128SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Complex128Var added in v1.1.3

func (f *FlagSet) Complex128Var(p *complex128, name string, value complex128, usage string)

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

func (*FlagSet) Complex128VarP added in v1.1.3

func (f *FlagSet) Complex128VarP(p *complex128, name, shorthand string, value complex128, usage string)

Complex128VarP is like Complex128Var, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Complex128VarS added in v1.1.3

func (f *FlagSet) Complex128VarS(p *complex128, name, shorthand string, value complex128, usage string)

Complex128VarS is like Complex128Var, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Count

func (f *FlagSet) Count(name string, usage string) *int

Count defines a count flag with specified name, default value, and usage string. The return value is the address of an int variable that stores the value of the flag. A count flag will add 1 to its value every time it is found on the command line

func (*FlagSet) CountP

func (f *FlagSet) CountP(name, shorthand string, usage string) *int

CountP is like Count only takes a shorthand for the flag name.

func (*FlagSet) CountS added in v1.1.3

func (f *FlagSet) CountS(name, shorthand string, usage string) *int

CountS is like Count only takes a shorthand for the flag name, alone.

func (*FlagSet) CountVar

func (f *FlagSet) CountVar(p *int, name string, usage string)

CountVar defines a count 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. A count flag will add 1 to its value every time it is found on the command line

func (*FlagSet) CountVarP

func (f *FlagSet) CountVarP(p *int, name, shorthand string, usage string)

CountVarP is like CountVar only take a shorthand for the flag name.

func (*FlagSet) CountVarS added in v1.1.3

func (f *FlagSet) CountVarS(p *int, name, shorthand string, usage string)

CountVarS is like CountVar only take a shorthand for the flag name, alone.

func (*FlagSet) Duration

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

Duration defines a time.Duration flag with specified name, default value, and usage string. The return value is the address of a time.Duration variable that stores the value of the flag.

func (*FlagSet) DurationP

func (f *FlagSet) DurationP(name, shorthand string, value time.Duration, usage string) *time.Duration

DurationP is like Duration, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) DurationS added in v1.1.3

func (f *FlagSet) DurationS(name, shorthand string, value time.Duration, usage string) *time.Duration

DurationS is like Duration, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) DurationSlice added in v1.0.1

func (f *FlagSet) DurationSlice(name string, value []time.Duration, usage string) *[]time.Duration

DurationSlice defines a []time.Duration flag with specified name, default value, and usage string. The return value is the address of a []time.Duration variable that stores the value of the flag.

func (*FlagSet) DurationSliceP added in v1.0.1

func (f *FlagSet) DurationSliceP(name, shorthand string, value []time.Duration, usage string) *[]time.Duration

DurationSliceP is like DurationSlice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) DurationSliceS added in v1.1.3

func (f *FlagSet) DurationSliceS(name, shorthand string, value []time.Duration, usage string) *[]time.Duration

DurationSliceS is like DurationSlice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) DurationSliceVar added in v1.0.1

func (f *FlagSet) DurationSliceVar(p *[]time.Duration, name string, value []time.Duration, usage string)

DurationSliceVar defines a durationSlice 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) DurationSliceVarP added in v1.0.1

func (f *FlagSet) DurationSliceVarP(p *[]time.Duration, name, shorthand string, value []time.Duration, usage string)

DurationSliceVarP is like DurationSliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) DurationSliceVarS added in v1.1.3

func (f *FlagSet) DurationSliceVarS(p *[]time.Duration, name, shorthand string, value []time.Duration, usage string)

DurationSliceVarS is like DurationSliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) DurationVar

func (f *FlagSet) DurationVar(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) DurationVarP

func (f *FlagSet) DurationVarP(p *time.Duration, name, shorthand string, value time.Duration, usage string)

DurationVarP is like DurationVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) DurationVarS added in v1.1.3

func (f *FlagSet) DurationVarS(p *time.Duration, name, shorthand string, value time.Duration, usage string)

DurationVarS is like DurationVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) FlagUsages

func (f *FlagSet) FlagUsages() string

FlagUsages returns a string containing the usage information for all flags in the FlagSet

func (*FlagSet) FlagUsagesWrapped

func (f *FlagSet) FlagUsagesWrapped(cols int) string

FlagUsagesWrapped returns a string containing the usage information for all flags in the FlagSet. Wrapped to `cols` columns (0 for no wrapping)

func (*FlagSet) Float32

func (f *FlagSet) Float32(name string, value float32, usage string) *float32

Float32 defines a float32 flag with specified name, default value, and usage string. The return value is the address of a float32 variable that stores the value of the flag.

func (*FlagSet) Float32P

func (f *FlagSet) Float32P(name, shorthand string, value float32, usage string) *float32

Float32P is like Float32, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Float32S added in v1.1.3

func (f *FlagSet) Float32S(name, shorthand string, value float32, usage string) *float32

Float32S is like Float32, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Float32Slice added in v1.1.3

func (f *FlagSet) Float32Slice(name string, value []float32, usage string) *[]float32

Float32Slice defines a []float32 flag with specified name, default value, and usage string. The return value is the address of a []float32 variable that stores the value of the flag.

func (*FlagSet) Float32SliceP added in v1.1.3

func (f *FlagSet) Float32SliceP(name, shorthand string, value []float32, usage string) *[]float32

Float32SliceP is like Float32Slice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Float32SliceS added in v1.1.3

func (f *FlagSet) Float32SliceS(name, shorthand string, value []float32, usage string) *[]float32

Float32SliceS is like Float32Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Float32SliceVar added in v1.1.3

func (f *FlagSet) Float32SliceVar(p *[]float32, name string, value []float32, usage string)

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

func (*FlagSet) Float32SliceVarP added in v1.1.3

func (f *FlagSet) Float32SliceVarP(p *[]float32, name, shorthand string, value []float32, usage string)

Float32SliceVarP is like Float32SliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Float32SliceVarS added in v1.1.3

func (f *FlagSet) Float32SliceVarS(p *[]float32, name, shorthand string, value []float32, usage string)

Float32SliceVarS is like Float32SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Float32Var

func (f *FlagSet) Float32Var(p *float32, name string, value float32, usage string)

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

func (*FlagSet) Float32VarP

func (f *FlagSet) Float32VarP(p *float32, name, shorthand string, value float32, usage string)

Float32VarP is like Float32Var, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Float32VarS added in v1.1.3

func (f *FlagSet) Float32VarS(p *float32, name, shorthand string, value float32, usage string)

Float32VarS is like Float32Var, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Float64

func (f *FlagSet) Float64(name string, value float64, usage string) *float64

Float64 defines a float64 flag with specified name, default value, and usage string. The return value is the address of a float64 variable that stores the value of the flag.

func (*FlagSet) Float64P

func (f *FlagSet) Float64P(name, shorthand string, value float64, usage string) *float64

Float64P is like Float64, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Float64S added in v1.1.3

func (f *FlagSet) Float64S(name, shorthand string, value float64, usage string) *float64

Float64S is like Float64, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Float64Slice added in v1.1.3

func (f *FlagSet) Float64Slice(name string, value []float64, usage string) *[]float64

Float64Slice defines a []float64 flag with specified name, default value, and usage string. The return value is the address of a []float64 variable that stores the value of the flag.

func (*FlagSet) Float64SliceP added in v1.1.3

func (f *FlagSet) Float64SliceP(name, shorthand string, value []float64, usage string) *[]float64

Float64SliceP is like Float64Slice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Float64SliceS added in v1.1.3

func (f *FlagSet) Float64SliceS(name, shorthand string, value []float64, usage string) *[]float64

Float64SliceS is like Float64Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Float64SliceVar added in v1.1.3

func (f *FlagSet) Float64SliceVar(p *[]float64, name string, value []float64, usage string)

Float64SliceVar defines a float64Slice 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) Float64SliceVarP added in v1.1.3

func (f *FlagSet) Float64SliceVarP(p *[]float64, name, shorthand string, value []float64, usage string)

Float64SliceVarP is like Float64SliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Float64SliceVarS added in v1.1.3

func (f *FlagSet) Float64SliceVarS(p *[]float64, name, shorthand string, value []float64, usage string)

Float64SliceVarS is like Float64SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Float64Var

func (f *FlagSet) Float64Var(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) Float64VarP

func (f *FlagSet) Float64VarP(p *float64, name, shorthand string, value float64, usage string)

Float64VarP is like Float64Var, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Float64VarS added in v1.1.3

func (f *FlagSet) Float64VarS(p *float64, name, shorthand string, value float64, usage string)

Float64VarS is like Float64Var, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) GetAllFlags added in v1.1.3

func (f *FlagSet) GetAllFlags() (flags []*Flag)

GetAllFlags return the flags in lexicographical order or in primordial order if f.SortFlags is false. It visits all flags, even those not set.

func (*FlagSet) GetBool

func (f *FlagSet) GetBool(name string) (bool, error)

GetBool return the bool value of a flag with the given name

func (*FlagSet) GetBoolSlice

func (f *FlagSet) GetBoolSlice(name string) ([]bool, error)

GetBoolSlice returns the []bool value of a flag with the given name.

func (*FlagSet) GetBytesBase64 added in v1.0.2

func (f *FlagSet) GetBytesBase64(name string) ([]byte, error)

GetBytesBase64 return the []byte value of a flag with the given name

func (*FlagSet) GetBytesHex added in v1.0.1

func (f *FlagSet) GetBytesHex(name string) ([]byte, error)

GetBytesHex return the []byte value of a flag with the given name

func (*FlagSet) GetComplex128 added in v1.1.3

func (f *FlagSet) GetComplex128(name string) (complex128, error)

GetComplex128 return the complex128 value of a flag with the given name

func (*FlagSet) GetComplex128Slice added in v1.1.3

func (f *FlagSet) GetComplex128Slice(name string) ([]complex128, error)

GetComplex128Slice return the []complex128 value of a flag with the given name

func (*FlagSet) GetCount

func (f *FlagSet) GetCount(name string) (int, error)

GetCount return the int value of a flag with the given name

func (*FlagSet) GetDuration

func (f *FlagSet) GetDuration(name string) (time.Duration, error)

GetDuration return the duration value of a flag with the given name

func (*FlagSet) GetDurationSlice added in v1.0.1

func (f *FlagSet) GetDurationSlice(name string) ([]time.Duration, error)

GetDurationSlice returns the []time.Duration value of a flag with the given name

func (*FlagSet) GetFlags added in v1.1.3

func (f *FlagSet) GetFlags() (flags []*Flag)

GetFlags return the flags in lexicographical order or in primordial order if f.SortFlags is false. It visits only those flags that have been set.

func (*FlagSet) GetFloat32

func (f *FlagSet) GetFloat32(name string) (float32, error)

GetFloat32 return the float32 value of a flag with the given name

func (*FlagSet) GetFloat32Slice added in v1.1.3

func (f *FlagSet) GetFloat32Slice(name string) ([]float32, error)

GetFloat32Slice return the []float32 value of a flag with the given name

func (*FlagSet) GetFloat64

func (f *FlagSet) GetFloat64(name string) (float64, error)

GetFloat64 return the float64 value of a flag with the given name

func (*FlagSet) GetFloat64Slice added in v1.1.3

func (f *FlagSet) GetFloat64Slice(name string) ([]float64, error)

GetFloat64Slice return the []float64 value of a flag with the given name

func (*FlagSet) GetIP

func (f *FlagSet) GetIP(name string) (net.IP, error)

GetIP return the net.IP value of a flag with the given name

func (*FlagSet) GetIPNet

func (f *FlagSet) GetIPNet(name string) (net.IPNet, error)

GetIPNet return the net.IPNet value of a flag with the given name

func (*FlagSet) GetIPNetSlice added in v1.1.3

func (f *FlagSet) GetIPNetSlice(name string) ([]net.IPNet, error)

GetIPNetSlice returns the []net.IPNet value of a flag with the given name

func (*FlagSet) GetIPSlice

func (f *FlagSet) GetIPSlice(name string) ([]net.IP, error)

GetIPSlice returns the []net.IP value of a flag with the given name

func (*FlagSet) GetIPv4Mask

func (f *FlagSet) GetIPv4Mask(name string) (net.IPMask, error)

GetIPv4Mask return the net.IPv4Mask value of a flag with the given name

func (*FlagSet) GetInt

func (f *FlagSet) GetInt(name string) (int, error)

GetInt return the int value of a flag with the given name

func (*FlagSet) GetInt16 added in v1.0.1

func (f *FlagSet) GetInt16(name string) (int16, error)

GetInt16 returns the int16 value of a flag with the given name

func (*FlagSet) GetInt16Slice added in v1.1.3

func (f *FlagSet) GetInt16Slice(name string) ([]int16, error)

GetInt16Slice return the []int16 value of a flag with the given name

func (*FlagSet) GetInt32

func (f *FlagSet) GetInt32(name string) (int32, error)

GetInt32 return the int32 value of a flag with the given name

func (*FlagSet) GetInt32Slice added in v1.1.3

func (f *FlagSet) GetInt32Slice(name string) ([]int32, error)

GetInt32Slice return the []int32 value of a flag with the given name

func (*FlagSet) GetInt64

func (f *FlagSet) GetInt64(name string) (int64, error)

GetInt64 return the int64 value of a flag with the given name

func (*FlagSet) GetInt64Slice added in v1.1.3

func (f *FlagSet) GetInt64Slice(name string) ([]int64, error)

GetInt64Slice return the []int64 value of a flag with the given name

func (*FlagSet) GetInt8

func (f *FlagSet) GetInt8(name string) (int8, error)

GetInt8 return the int8 value of a flag with the given name

func (*FlagSet) GetInt8Slice added in v1.1.3

func (f *FlagSet) GetInt8Slice(name string) ([]int8, error)

GetInt8Slice return the []int8 value of a flag with the given name

func (*FlagSet) GetIntSlice

func (f *FlagSet) GetIntSlice(name string) ([]int, error)

GetIntSlice return the []int value of a flag with the given name

func (*FlagSet) GetNormalizeFunc

func (f *FlagSet) GetNormalizeFunc() func(f *FlagSet, name string) NormalizedName

GetNormalizeFunc returns the previously set NormalizeFunc of a function which does no translation, if not set previously.

func (*FlagSet) GetString

func (f *FlagSet) GetString(name string) (string, error)

GetString return the string value of a flag with the given name

func (*FlagSet) GetStringArray

func (f *FlagSet) GetStringArray(name string) ([]string, error)

GetStringArray return the []string value of a flag with the given name

func (*FlagSet) GetStringSlice

func (f *FlagSet) GetStringSlice(name string) ([]string, error)

GetStringSlice return the []string value of a flag with the given name

func (*FlagSet) GetStringToInt added in v1.0.3

func (f *FlagSet) GetStringToInt(name string) (map[string]int, error)

GetStringToInt return the map[string]int value of a flag with the given name

func (*FlagSet) GetStringToInt64 added in v1.1.3

func (f *FlagSet) GetStringToInt64(name string) (map[string]int64, error)

GetStringToInt64 return the map[string]int64 value of a flag with the given name

func (*FlagSet) GetStringToString added in v1.0.3

func (f *FlagSet) GetStringToString(name string) (map[string]string, error)

GetStringToString return the map[string]string value of a flag with the given name

func (*FlagSet) GetUint

func (f *FlagSet) GetUint(name string) (uint, error)

GetUint return the uint value of a flag with the given name

func (*FlagSet) GetUint16

func (f *FlagSet) GetUint16(name string) (uint16, error)

GetUint16 return the uint16 value of a flag with the given name

func (*FlagSet) GetUint16Slice added in v1.1.3

func (f *FlagSet) GetUint16Slice(name string) ([]uint16, error)

GetUint16Slice return the []uint16 value of a flag with the given name

func (*FlagSet) GetUint32

func (f *FlagSet) GetUint32(name string) (uint32, error)

GetUint32 return the uint32 value of a flag with the given name

func (*FlagSet) GetUint32Slice added in v1.1.3

func (f *FlagSet) GetUint32Slice(name string) ([]uint32, error)

GetUint32Slice return the []uint32 value of a flag with the given name

func (*FlagSet) GetUint64

func (f *FlagSet) GetUint64(name string) (uint64, error)

GetUint64 return the uint64 value of a flag with the given name

func (*FlagSet) GetUint64Slice added in v1.1.3

func (f *FlagSet) GetUint64Slice(name string) ([]uint64, error)

GetUint64Slice return the []uint64 value of a flag with the given name

func (*FlagSet) GetUint8

func (f *FlagSet) GetUint8(name string) (uint8, error)

GetUint8 return the uint8 value of a flag with the given name

func (*FlagSet) GetUint8Slice added in v1.1.3

func (f *FlagSet) GetUint8Slice(name string) ([]uint8, error)

GetUint8Slice return the []uint8 value of a flag with the given name

func (*FlagSet) GetUintSlice

func (f *FlagSet) GetUintSlice(name string) ([]uint, error)

GetUintSlice returns the []uint value of a flag with the given name.

func (*FlagSet) GetUnknownFlags added in v1.1.3

func (f *FlagSet) GetUnknownFlags() []string

GetUnknownFlags returns unknown flags in the order they were Parsed. This requires ParseErrorsWhitelist.UnknownFlags to be set so that parsing does not abort on the first unknown flag.

func (*FlagSet) HasAvailableFlags

func (f *FlagSet) HasAvailableFlags() bool

HasAvailableFlags returns a bool to indicate if the FlagSet has any flags that are not hidden.

func (*FlagSet) HasFlags

func (f *FlagSet) HasFlags() bool

HasFlags returns a bool to indicate if the FlagSet has any flags defined.

func (*FlagSet) IP

func (f *FlagSet) IP(name string, value net.IP, usage string) *net.IP

IP defines an net.IP flag with specified name, default value, and usage string. The return value is the address of an net.IP variable that stores the value of the flag.

func (*FlagSet) IPMask

func (f *FlagSet) IPMask(name string, value net.IPMask, usage string) *net.IPMask

IPMask defines an net.IPMask flag with specified name, default value, and usage string. The return value is the address of an net.IPMask variable that stores the value of the flag.

func (*FlagSet) IPMaskP

func (f *FlagSet) IPMaskP(name, shorthand string, value net.IPMask, usage string) *net.IPMask

IPMaskP is like IPMask, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) IPMaskS added in v1.1.3

func (f *FlagSet) IPMaskS(name, shorthand string, value net.IPMask, usage string) *net.IPMask

IPMaskS is like IPMask, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) IPMaskVar

func (f *FlagSet) IPMaskVar(p *net.IPMask, name string, value net.IPMask, usage string)

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

func (*FlagSet) IPMaskVarP

func (f *FlagSet) IPMaskVarP(p *net.IPMask, name, shorthand string, value net.IPMask, usage string)

IPMaskVarP is like IPMaskVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) IPMaskVarS added in v1.1.3

func (f *FlagSet) IPMaskVarS(p *net.IPMask, name, shorthand string, value net.IPMask, usage string)

IPMaskVarS is like IPMaskVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) IPNet

func (f *FlagSet) IPNet(name string, value net.IPNet, usage string) *net.IPNet

IPNet defines an net.IPNet flag with specified name, default value, and usage string. The return value is the address of an net.IPNet variable that stores the value of the flag.

func (*FlagSet) IPNetP

func (f *FlagSet) IPNetP(name, shorthand string, value net.IPNet, usage string) *net.IPNet

IPNetP is like IPNet, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) IPNetS added in v1.1.3

func (f *FlagSet) IPNetS(name, shorthand string, value net.IPNet, usage string) *net.IPNet

IPNetS is like IPNet, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) IPNetSlice added in v1.1.3

func (f *FlagSet) IPNetSlice(name string, value []net.IPNet, usage string) *[]net.IPNet

IPNetSlice defines a []net.IPNet flag with specified name, default value, and usage string. The return value is the address of a []net.IPNet variable that stores the value of that flag.

func (*FlagSet) IPNetSliceP added in v1.1.3

func (f *FlagSet) IPNetSliceP(name, shorthand string, value []net.IPNet, usage string) *[]net.IPNet

IPNetSliceP is like IPNetSlice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) IPNetSliceS added in v1.1.3

func (f *FlagSet) IPNetSliceS(name, shorthand string, value []net.IPNet, usage string) *[]net.IPNet

IPNetSliceS is like IPNetSlice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) IPNetSliceVar added in v1.1.3

func (f *FlagSet) IPNetSliceVar(p *[]net.IPNet, name string, value []net.IPNet, usage string)

IPNetSliceVar defines a ipNetSlice flag with specified name, default value, and usage string. The argument p points to a []net.IPNet variable in which to store the value of the flag.

func (*FlagSet) IPNetSliceVarP added in v1.1.3

func (f *FlagSet) IPNetSliceVarP(p *[]net.IPNet, name, shorthand string, value []net.IPNet, usage string)

IPNetSliceVarP is like IPNetSliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) IPNetSliceVarS added in v1.1.3

func (f *FlagSet) IPNetSliceVarS(p *[]net.IPNet, name, shorthand string, value []net.IPNet, usage string)

IPNetSliceVarS is like IPNetSliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) IPNetVar

func (f *FlagSet) IPNetVar(p *net.IPNet, name string, value net.IPNet, usage string)

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

func (*FlagSet) IPNetVarP

func (f *FlagSet) IPNetVarP(p *net.IPNet, name, shorthand string, value net.IPNet, usage string)

IPNetVarP is like IPNetVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) IPNetVarS added in v1.1.3

func (f *FlagSet) IPNetVarS(p *net.IPNet, name, shorthand string, value net.IPNet, usage string)

IPNetVarS is like IPNetVar, but accepts a shorthand letter that can be used after a single , alone, alone.

func (*FlagSet) IPP

func (f *FlagSet) IPP(name, shorthand string, value net.IP, usage string) *net.IP

IPP is like IP, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) IPS added in v1.1.3

func (f *FlagSet) IPS(name, shorthand string, value net.IP, usage string) *net.IP

IPS is like IP, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) IPSlice

func (f *FlagSet) IPSlice(name string, value []net.IP, usage string) *[]net.IP

IPSlice defines a []net.IP flag with specified name, default value, and usage string. The return value is the address of a []net.IP variable that stores the value of that flag.

func (*FlagSet) IPSliceP

func (f *FlagSet) IPSliceP(name, shorthand string, value []net.IP, usage string) *[]net.IP

IPSliceP is like IPSlice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) IPSliceS added in v1.1.3

func (f *FlagSet) IPSliceS(name, shorthand string, value []net.IP, usage string) *[]net.IP

IPSliceS is like IPSlice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) IPSliceVar

func (f *FlagSet) IPSliceVar(p *[]net.IP, name string, value []net.IP, usage string)

IPSliceVar defines a ipSlice flag with specified name, default value, and usage string. The argument p points to a []net.IP variable in which to store the value of the flag.

func (*FlagSet) IPSliceVarP

func (f *FlagSet) IPSliceVarP(p *[]net.IP, name, shorthand string, value []net.IP, usage string)

IPSliceVarP is like IPSliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) IPSliceVarS added in v1.1.3

func (f *FlagSet) IPSliceVarS(p *[]net.IP, name, shorthand string, value []net.IP, usage string)

IPSliceVarS is like IPSliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) IPVar

func (f *FlagSet) IPVar(p *net.IP, name string, value net.IP, usage string)

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

func (*FlagSet) IPVarP

func (f *FlagSet) IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string)

IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) IPVarS added in v1.1.3

func (f *FlagSet) IPVarS(p *net.IP, name, shorthand string, value net.IP, usage string)

IPVarS is like IPVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Init

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

Init sets the name and error handling property for a flag set. By default, the zero FlagSet uses an empty name and the ContinueOnError error handling policy.

func (*FlagSet) Int

func (f *FlagSet) Int(name string, value int, usage string) *int

Int defines an int flag with specified name, default value, and usage string. The return value is the address of an int variable that stores the value of the flag.

func (*FlagSet) Int16 added in v1.0.1

func (f *FlagSet) Int16(name string, value int16, usage string) *int16

Int16 defines an int16 flag with specified name, default value, and usage string. The return value is the address of an int16 variable that stores the value of the flag.

func (*FlagSet) Int16P added in v1.0.1

func (f *FlagSet) Int16P(name, shorthand string, value int16, usage string) *int16

Int16P is like Int16, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Int16S added in v1.1.3

func (f *FlagSet) Int16S(name, shorthand string, value int16, usage string) *int16

Int16S is like Int16, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Int16Slice added in v1.1.3

func (f *FlagSet) Int16Slice(name string, value []int16, usage string) *[]int16

Int16Slice defines a []int16 flag with specified name, default value, and usage string. The return value is the address of a []int16 variable that stores the value of the flag.

func (*FlagSet) Int16SliceP added in v1.1.3

func (f *FlagSet) Int16SliceP(name, shorthand string, value []int16, usage string) *[]int16

Int16SliceP is like Int16Slice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Int16SliceS added in v1.1.3

func (f *FlagSet) Int16SliceS(name, shorthand string, value []int16, usage string) *[]int16

Int16SliceS is like Int16Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Int16SliceVar added in v1.1.3

func (f *FlagSet) Int16SliceVar(p *[]int16, name string, value []int16, usage string)

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

func (*FlagSet) Int16SliceVarP added in v1.1.3

func (f *FlagSet) Int16SliceVarP(p *[]int16, name, shorthand string, value []int16, usage string)

Int16SliceVarP is like Int16SliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Int16SliceVarS added in v1.1.3

func (f *FlagSet) Int16SliceVarS(p *[]int16, name, shorthand string, value []int16, usage string)

Int16SliceVarS is like Int16SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Int16Var added in v1.0.1

func (f *FlagSet) Int16Var(p *int16, name string, value int16, usage string)

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

func (*FlagSet) Int16VarP added in v1.0.1

func (f *FlagSet) Int16VarP(p *int16, name, shorthand string, value int16, usage string)

Int16VarP is like Int16Var, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Int16VarS added in v1.1.3

func (f *FlagSet) Int16VarS(p *int16, name, shorthand string, value int16, usage string)

Int16VarS is like Int16Var, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Int32

func (f *FlagSet) Int32(name string, value int32, usage string) *int32

Int32 defines an int32 flag with specified name, default value, and usage string. The return value is the address of an int32 variable that stores the value of the flag.

func (*FlagSet) Int32P

func (f *FlagSet) Int32P(name, shorthand string, value int32, usage string) *int32

Int32P is like Int32, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Int32S added in v1.1.3

func (f *FlagSet) Int32S(name, shorthand string, value int32, usage string) *int32

Int32S is like Int32, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Int32Slice added in v1.1.3

func (f *FlagSet) Int32Slice(name string, value []int32, usage string) *[]int32

Int32Slice defines a []int32 flag with specified name, default value, and usage string. The return value is the address of a []int32 variable that stores the value of the flag.

func (*FlagSet) Int32SliceP added in v1.1.3

func (f *FlagSet) Int32SliceP(name, shorthand string, value []int32, usage string) *[]int32

Int32SliceP is like Int32Slice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Int32SliceS added in v1.1.3

func (f *FlagSet) Int32SliceS(name, shorthand string, value []int32, usage string) *[]int32

Int32SliceS is like Int32Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Int32SliceVar added in v1.1.3

func (f *FlagSet) Int32SliceVar(p *[]int32, name string, value []int32, usage string)

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

func (*FlagSet) Int32SliceVarP added in v1.1.3

func (f *FlagSet) Int32SliceVarP(p *[]int32, name, shorthand string, value []int32, usage string)

Int32SliceVarP is like Int32SliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Int32SliceVarS added in v1.1.3

func (f *FlagSet) Int32SliceVarS(p *[]int32, name, shorthand string, value []int32, usage string)

Int32SliceVarS is like Int32SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Int32Var

func (f *FlagSet) Int32Var(p *int32, name string, value int32, usage string)

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

func (*FlagSet) Int32VarP

func (f *FlagSet) Int32VarP(p *int32, name, shorthand string, value int32, usage string)

Int32VarP is like Int32Var, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Int32VarS added in v1.1.3

func (f *FlagSet) Int32VarS(p *int32, name, shorthand string, value int32, usage string)

Int32VarS is like Int32Var, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Int64

func (f *FlagSet) Int64(name string, value int64, usage string) *int64

Int64 defines an int64 flag with specified name, default value, and usage string. The return value is the address of an int64 variable that stores the value of the flag.

func (*FlagSet) Int64P

func (f *FlagSet) Int64P(name, shorthand string, value int64, usage string) *int64

Int64P is like Int64, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Int64S added in v1.1.3

func (f *FlagSet) Int64S(name, shorthand string, value int64, usage string) *int64

Int64S is like Int64, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Int64Slice added in v1.1.3

func (f *FlagSet) Int64Slice(name string, value []int64, usage string) *[]int64

Int64Slice defines a []int64 flag with specified name, default value, and usage string. The return value is the address of a []int64 variable that stores the value of the flag.

func (*FlagSet) Int64SliceP added in v1.1.3

func (f *FlagSet) Int64SliceP(name, shorthand string, value []int64, usage string) *[]int64

Int64SliceP is like Int64Slice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Int64SliceS added in v1.1.3

func (f *FlagSet) Int64SliceS(name, shorthand string, value []int64, usage string) *[]int64

Int64SliceS is like Int64Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Int64SliceVar added in v1.1.3

func (f *FlagSet) Int64SliceVar(p *[]int64, name string, value []int64, usage string)

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

func (*FlagSet) Int64SliceVarP added in v1.1.3

func (f *FlagSet) Int64SliceVarP(p *[]int64, name, shorthand string, value []int64, usage string)

Int64SliceVarP is like Int64SliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Int64SliceVarS added in v1.1.3

func (f *FlagSet) Int64SliceVarS(p *[]int64, name, shorthand string, value []int64, usage string)

Int64SliceVarS is like Int64SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Int64Var

func (f *FlagSet) Int64Var(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) Int64VarP

func (f *FlagSet) Int64VarP(p *int64, name, shorthand string, value int64, usage string)

Int64VarP is like Int64Var, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Int64VarS added in v1.1.3

func (f *FlagSet) Int64VarS(p *int64, name, shorthand string, value int64, usage string)

Int64VarS is like Int64Var, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Int8

func (f *FlagSet) Int8(name string, value int8, usage string) *int8

Int8 defines an int8 flag with specified name, default value, and usage string. The return value is the address of an int8 variable that stores the value of the flag.

func (*FlagSet) Int8P

func (f *FlagSet) Int8P(name, shorthand string, value int8, usage string) *int8

Int8P is like Int8, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Int8S added in v1.1.3

func (f *FlagSet) Int8S(name, shorthand string, value int8, usage string) *int8

Int8S is like Int8, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Int8Slice added in v1.1.3

func (f *FlagSet) Int8Slice(name string, value []int8, usage string) *[]int8

Int8Slice defines a []int8 flag with specified name, default value, and usage string. The return value is the address of a []int8 variable that stores the value of the flag.

func (*FlagSet) Int8SliceP added in v1.1.3

func (f *FlagSet) Int8SliceP(name, shorthand string, value []int8, usage string) *[]int8

Int8SliceP is like Int8Slice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Int8SliceS added in v1.1.3

func (f *FlagSet) Int8SliceS(name, shorthand string, value []int8, usage string) *[]int8

Int8SliceS is like Int8Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Int8SliceVar added in v1.1.3

func (f *FlagSet) Int8SliceVar(p *[]int8, name string, value []int8, usage string)

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

func (*FlagSet) Int8SliceVarP added in v1.1.3

func (f *FlagSet) Int8SliceVarP(p *[]int8, name, shorthand string, value []int8, usage string)

Int8SliceVarP is like Int8SliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Int8SliceVarS added in v1.1.3

func (f *FlagSet) Int8SliceVarS(p *[]int8, name, shorthand string, value []int8, usage string)

Int8SliceVarS is like Int8SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Int8Var

func (f *FlagSet) Int8Var(p *int8, name string, value int8, usage string)

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

func (*FlagSet) Int8VarP

func (f *FlagSet) Int8VarP(p *int8, name, shorthand string, value int8, usage string)

Int8VarP is like Int8Var, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Int8VarS added in v1.1.3

func (f *FlagSet) Int8VarS(p *int8, name, shorthand string, value int8, usage string)

Int8VarS is like Int8Var, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) IntP

func (f *FlagSet) IntP(name, shorthand string, value int, usage string) *int

IntP is like Int, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) IntS added in v1.1.3

func (f *FlagSet) IntS(name, shorthand string, value int, usage string) *int

IntS is like Int, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) IntSlice

func (f *FlagSet) IntSlice(name string, value []int, usage string) *[]int

IntSlice defines a []int flag with specified name, default value, and usage string. The return value is the address of a []int variable that stores the value of the flag.

func (*FlagSet) IntSliceP

func (f *FlagSet) IntSliceP(name, shorthand string, value []int, usage string) *[]int

IntSliceP is like IntSlice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) IntSliceS added in v1.1.3

func (f *FlagSet) IntSliceS(name, shorthand string, value []int, usage string) *[]int

IntSliceS is like IntSlice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) IntSliceVar

func (f *FlagSet) IntSliceVar(p *[]int, name string, value []int, usage string)

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

func (*FlagSet) IntSliceVarP

func (f *FlagSet) IntSliceVarP(p *[]int, name, shorthand string, value []int, usage string)

IntSliceVarP is like IntSliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) IntSliceVarS added in v1.1.3

func (f *FlagSet) IntSliceVarS(p *[]int, name, shorthand string, value []int, usage string)

IntSliceVarS is like IntSliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) IntVar

func (f *FlagSet) IntVar(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) IntVarP

func (f *FlagSet) IntVarP(p *int, name, shorthand string, value int, usage string)

IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) IntVarS added in v1.1.3

func (f *FlagSet) IntVarS(p *int, name, shorthand string, value int, usage string)

IntVarS is like IntVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Lookup

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

Lookup returns the Flag structure of the named flag, returning nil if none exists.

func (*FlagSet) MarkDeprecated

func (f *FlagSet) MarkDeprecated(name string, usageMessage string) error

MarkDeprecated indicated that a flag is deprecated in your program. It will continue to function but will not show up in help or usage messages. Using this flag will also print the given usageMessage.

func (*FlagSet) MarkHidden

func (f *FlagSet) MarkHidden(name string) error

MarkHidden sets a flag to 'hidden' in your program. It will continue to function but will not show up in help or usage messages.

func (*FlagSet) MarkShorthandDeprecated

func (f *FlagSet) MarkShorthandDeprecated(name string, usageMessage string) error

MarkShorthandDeprecated will mark the shorthand of a flag deprecated in your program. It will continue to function but will not show up in help or usage messages. Using this flag will also print the given usageMessage.

func (*FlagSet) MustGetBool added in v1.1.3

func (f *FlagSet) MustGetBool(name string) bool

MustGetBool is like GetBool, but panics on error.

func (*FlagSet) MustGetBoolSlice added in v1.1.3

func (f *FlagSet) MustGetBoolSlice(name string) []bool

MustGetBoolSlice is like GetBoolSlice, but panics on error.

func (*FlagSet) MustGetBytesBase64 added in v1.1.3

func (f *FlagSet) MustGetBytesBase64(name string) []byte

MustGetBytesBase64 is like GetBytesBase64, but panics on error.

func (*FlagSet) MustGetBytesHex added in v1.1.3

func (f *FlagSet) MustGetBytesHex(name string) []byte

MustGetBytesHex is like GetBytesHex, but panics on error.

func (*FlagSet) MustGetComplex128 added in v1.1.3

func (f *FlagSet) MustGetComplex128(name string) complex128

MustGetComplex128 is like GetComplex128, but panics on error.

func (*FlagSet) MustGetComplex128Slice added in v1.1.3

func (f *FlagSet) MustGetComplex128Slice(name string) []complex128

MustGetComplex128Slice is like GetComplex128Slice, but panics on error.

func (*FlagSet) MustGetCount added in v1.1.3

func (f *FlagSet) MustGetCount(name string) int

MustGetCount is like GetCount, but panics on error.

func (*FlagSet) MustGetDuration added in v1.1.3

func (f *FlagSet) MustGetDuration(name string) time.Duration

MustGetDuration is like GetDuration, but panics on error.

func (*FlagSet) MustGetDurationSlice added in v1.1.3

func (f *FlagSet) MustGetDurationSlice(name string) []time.Duration

MustGetDurationSlice is like GetDurationSlice, but panics on error.

func (*FlagSet) MustGetFloat32 added in v1.1.3

func (f *FlagSet) MustGetFloat32(name string) float32

MustGetFloat32 is like GetFloat32, but panics on error.

func (*FlagSet) MustGetFloat32Slice added in v1.1.3

func (f *FlagSet) MustGetFloat32Slice(name string) []float32

MustGetFloat32Slice is like GetFloat32Slice, but panics on error.

func (*FlagSet) MustGetFloat64 added in v1.1.3

func (f *FlagSet) MustGetFloat64(name string) float64

MustGetFloat64 is like GetFloat64, but panics on error.

func (*FlagSet) MustGetFloat64Slice added in v1.1.3

func (f *FlagSet) MustGetFloat64Slice(name string) []float64

MustGetFloat64Slice is like GetFloat64Slice, but panics on error.

func (*FlagSet) MustGetIP added in v1.1.3

func (f *FlagSet) MustGetIP(name string) net.IP

MustGetIP is like GetIP, but panics on error.

func (*FlagSet) MustGetIPNet added in v1.1.3

func (f *FlagSet) MustGetIPNet(name string) net.IPNet

MustGetIPNet is like GetIPNet, but panics on error.

func (*FlagSet) MustGetIPNetSlice added in v1.1.3

func (f *FlagSet) MustGetIPNetSlice(name string) []net.IPNet

MustGetIPNetSlice is like GetIPNetSlice, but panics on error.

func (*FlagSet) MustGetIPSlice added in v1.1.3

func (f *FlagSet) MustGetIPSlice(name string) []net.IP

MustGetIPSlice is like GetIPSlice, but panics on error.

func (*FlagSet) MustGetIPv4Mask added in v1.1.3

func (f *FlagSet) MustGetIPv4Mask(name string) net.IPMask

MustGetIPv4Mask is like GetIPv4Mask, but panics on error.

func (*FlagSet) MustGetInt added in v1.1.3

func (f *FlagSet) MustGetInt(name string) int

MustGetInt is like GetInt, but panics on error.

func (*FlagSet) MustGetInt16 added in v1.1.3

func (f *FlagSet) MustGetInt16(name string) int16

MustGetInt16 is like GetInt16, but panics on error.

func (*FlagSet) MustGetInt16Slice added in v1.1.3

func (f *FlagSet) MustGetInt16Slice(name string) []int16

MustGetInt16Slice is like GetInt16Slice, but panics on error.

func (*FlagSet) MustGetInt32 added in v1.1.3

func (f *FlagSet) MustGetInt32(name string) int32

MustGetInt32 is like GetInt32, but panics on error.

func (*FlagSet) MustGetInt32Slice added in v1.1.3

func (f *FlagSet) MustGetInt32Slice(name string) []int32

MustGetInt32Slice is like GetInt32Slice, but panics on error.

func (*FlagSet) MustGetInt64 added in v1.1.3

func (f *FlagSet) MustGetInt64(name string) int64

MustGetInt64 is like GetInt64, but panics on error.

func (*FlagSet) MustGetInt64Slice added in v1.1.3

func (f *FlagSet) MustGetInt64Slice(name string) []int64

MustGetInt64Slice is like GetInt64Slice, but panics on error.

func (*FlagSet) MustGetInt8 added in v1.1.3

func (f *FlagSet) MustGetInt8(name string) int8

MustGetInt8 is like GetInt8, but panics on error.

func (*FlagSet) MustGetInt8Slice added in v1.1.3

func (f *FlagSet) MustGetInt8Slice(name string) []int8

MustGetInt8Slice is like GetInt8Slice, but panics on error.

func (*FlagSet) MustGetIntSlice added in v1.1.3

func (f *FlagSet) MustGetIntSlice(name string) []int

MustGetIntSlice is like GetIntSlice, but panics on error.

func (*FlagSet) MustGetString added in v1.1.3

func (f *FlagSet) MustGetString(name string) string

MustGetString is like GetString, but panics on error.

func (*FlagSet) MustGetStringArray added in v1.1.3

func (f *FlagSet) MustGetStringArray(name string) []string

MustGetStringArray is like GetStringArray, but panics on error.

func (*FlagSet) MustGetStringSlice added in v1.1.3

func (f *FlagSet) MustGetStringSlice(name string) []string

MustGetStringSlice is like GetStringSlice, but panics on error.

func (*FlagSet) MustGetStringToInt added in v1.1.3

func (f *FlagSet) MustGetStringToInt(name string) map[string]int

MustGetStringToInt is like GetStringToInt, but panics on error.

func (*FlagSet) MustGetStringToInt64 added in v1.1.3

func (f *FlagSet) MustGetStringToInt64(name string) map[string]int64

MustGetStringToInt64 is like GetStringToInt64, but panics on error.

func (*FlagSet) MustGetStringToString added in v1.1.3

func (f *FlagSet) MustGetStringToString(name string) map[string]string

MustGetStringToString is like GetStringToString, but panics on error.

func (*FlagSet) MustGetUint added in v1.1.3

func (f *FlagSet) MustGetUint(name string) uint

MustGetUint is like GetUint, but panics on error.

func (*FlagSet) MustGetUint16 added in v1.1.3

func (f *FlagSet) MustGetUint16(name string) uint16

MustGetUint16 is like GetUint16, but panics on error.

func (*FlagSet) MustGetUint16Slice added in v1.1.3

func (f *FlagSet) MustGetUint16Slice(name string) []uint16

MustGetUint16Slice is like GetUint16Slice, but panics on error.

func (*FlagSet) MustGetUint32 added in v1.1.3

func (f *FlagSet) MustGetUint32(name string) uint32

MustGetUint32 is like GetUint32, but panics on error.

func (*FlagSet) MustGetUint32Slice added in v1.1.3

func (f *FlagSet) MustGetUint32Slice(name string) []uint32

MustGetUint32Slice is like GetUint32Slice, but panics on error.

func (*FlagSet) MustGetUint64 added in v1.1.3

func (f *FlagSet) MustGetUint64(name string) uint64

MustGetUint64 is like GetUint64, but panics on error.

func (*FlagSet) MustGetUint64Slice added in v1.1.3

func (f *FlagSet) MustGetUint64Slice(name string) []uint64

MustGetUint64Slice is like GetUint64Slice, but panics on error.

func (*FlagSet) MustGetUint8 added in v1.1.3

func (f *FlagSet) MustGetUint8(name string) uint8

MustGetUint8 is like GetUint8, but panics on error.

func (*FlagSet) MustGetUint8Slice added in v1.1.3

func (f *FlagSet) MustGetUint8Slice(name string) []uint8

MustGetUint8Slice is like GetUint8Slice, but panics on error.

func (*FlagSet) MustGetUintSlice added in v1.1.3

func (f *FlagSet) MustGetUintSlice(name string) []uint

MustGetUintSlice is like GetUintSlice, but panics on error.

func (*FlagSet) NArg

func (f *FlagSet) NArg() int

NArg is the number of arguments remaining after flags have been processed.

func (*FlagSet) NFlag

func (f *FlagSet) NFlag() int

NFlag returns the number of flags that have been set.

func (*FlagSet) Name added in v1.1.3

func (f *FlagSet) Name() string

Name returns the name of the flag set.

func (*FlagSet) Output added in v1.1.3

func (f *FlagSet) Output() io.Writer

Output returns the destination for usage and error messages. os.Stderr is returned if output was not set or was set to nil.

func (*FlagSet) Parse

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

Parse parses flag definitions from the argument list, which should not include the command name. Must be called after all flags in the FlagSet are defined and before flags are accessed by the program. The return value will be ErrHelp if -help was set but not defined.

func (*FlagSet) ParseAll

func (f *FlagSet) ParseAll(arguments []string, fn func(flag *Flag, value string) error) error

ParseAll parses flag definitions from the argument list, which should not include the command name. The arguments for fn are flag and value. Must be called after all flags in the FlagSet are defined and before flags are accessed by the program. The return value will be ErrHelp if -help was set but not defined.

func (*FlagSet) Parsed

func (f *FlagSet) Parsed() bool

Parsed reports whether f.Parse has been called.

func (*FlagSet) PrintDefaults

func (f *FlagSet) PrintDefaults()

PrintDefaults prints to standard error unless configured otherwise, the default values of all defined command-line flags in the set. See the documentation for the global function PrintDefaults for more information.

func (*FlagSet) Set

func (f *FlagSet) Set(name, value string) error

Set sets the value of the named flag.

func (*FlagSet) SetAnnotation

func (f *FlagSet) SetAnnotation(name, key string, values []string) error

SetAnnotation allows one to set arbitrary annotations on a flag in the FlagSet. This is sometimes used by spf13/cobra programs which want to generate additional bash completion information.

func (*FlagSet) SetInterspersed

func (f *FlagSet) SetInterspersed(interspersed bool)

SetInterspersed sets whether to support interspersed option/non-option arguments.

func (*FlagSet) SetNormalizeFunc

func (f *FlagSet) SetNormalizeFunc(n func(f *FlagSet, name string) NormalizedName)

SetNormalizeFunc allows you to add a function which can translate flag names. Flags added to the FlagSet will be translated and then when anything tries to look up the flag that will also be translated. So it would be possible to create a flag named "getURL" and have it translated to "geturl". A user could then pass "--getUrl" which may also be translated to "geturl" and everything will work.

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) ShorthandLookup

func (f *FlagSet) ShorthandLookup(name string) *Flag

ShorthandLookup returns the Flag structure of the short handed flag, returning nil if none exists. It panics, if len(name) > 1.

Example
name := "verbose"
short := name[:1]

fs := NewFlagSet("Example", ContinueOnError)
fs.BoolP(name, short, false, "verbose output")

// len(short) must be == 1
flag := fs.ShorthandLookup(short)

fmt.Println(flag.Name)
Output:

func (*FlagSet) String

func (f *FlagSet) String(name string, value string, usage string) *string

String defines a string flag with specified name, default value, and usage string. The return value is the address of a string variable that stores the value of the flag.

func (*FlagSet) StringArray

func (f *FlagSet) StringArray(name string, value []string, usage string) *[]string

StringArray defines a string flag with specified name, default value, and usage string. The return value is the address of a []string variable that stores the value of the flag. The value of each argument will not try to be separated by comma. Use a StringSlice for that.

func (*FlagSet) StringArrayP

func (f *FlagSet) StringArrayP(name, shorthand string, value []string, usage string) *[]string

StringArrayP is like StringArray, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) StringArrayS added in v1.1.3

func (f *FlagSet) StringArrayS(name, shorthand string, value []string, usage string) *[]string

StringArrayS is like StringArray, but accepts a shorthand letter that can be used after a single , alone, alone.

func (*FlagSet) StringArrayVar

func (f *FlagSet) StringArrayVar(p *[]string, name string, value []string, usage string)

StringArrayVar 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 values of the multiple flags. The value of each argument will not try to be separated by comma. Use a StringSlice for that.

func (*FlagSet) StringArrayVarP

func (f *FlagSet) StringArrayVarP(p *[]string, name, shorthand string, value []string, usage string)

StringArrayVarP is like StringArrayVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) StringArrayVarS added in v1.1.3

func (f *FlagSet) StringArrayVarS(p *[]string, name, shorthand string, value []string, usage string)

StringArrayVarS is like StringArrayVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) StringP

func (f *FlagSet) StringP(name, shorthand string, value string, usage string) *string

StringP is like String, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) StringS added in v1.1.3

func (f *FlagSet) StringS(name, shorthand string, value string, usage string) *string

StringS is like String, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) StringSlice

func (f *FlagSet) StringSlice(name string, value []string, usage string) *[]string

StringSlice defines a string flag with specified name, default value, and usage string. The return value is the address of a []string variable that stores the value of the flag. Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly. For example:

--ss="v1,v2" --ss="v3"

will result in

[]string{"v1", "v2", "v3"}

func (*FlagSet) StringSliceP

func (f *FlagSet) StringSliceP(name, shorthand string, value []string, usage string) *[]string

StringSliceP is like StringSlice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) StringSliceS added in v1.1.3

func (f *FlagSet) StringSliceS(name, shorthand string, value []string, usage string) *[]string

StringSliceS is like StringSlice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) StringSliceVar

func (f *FlagSet) StringSliceVar(p *[]string, name string, value []string, usage string)

StringSliceVar 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. Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly. For example:

--ss="v1,v2" --ss="v3"

will result in

[]string{"v1", "v2", "v3"}

func (*FlagSet) StringSliceVarP

func (f *FlagSet) StringSliceVarP(p *[]string, name, shorthand string, value []string, usage string)

StringSliceVarP is like StringSliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) StringSliceVarS added in v1.1.3

func (f *FlagSet) StringSliceVarS(p *[]string, name, shorthand string, value []string, usage string)

StringSliceVarS is like StringSliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) StringToInt added in v1.0.3

func (f *FlagSet) StringToInt(name string, value map[string]int, usage string) *map[string]int

StringToInt defines a string flag with specified name, default value, and usage string. The return value is the address of a map[string]int variable that stores the value of the flag. The value of each argument will not try to be separated by comma

func (*FlagSet) StringToInt64 added in v1.1.3

func (f *FlagSet) StringToInt64(name string, value map[string]int64, usage string) *map[string]int64

StringToInt64 defines a string flag with specified name, default value, and usage string. The return value is the address of a map[string]int64 variable that stores the value of the flag. The value of each argument will not try to be separated by comma

func (*FlagSet) StringToInt64P added in v1.1.3

func (f *FlagSet) StringToInt64P(name, shorthand string, value map[string]int64, usage string) *map[string]int64

StringToInt64P is like StringToInt64, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) StringToInt64S added in v1.1.3

func (f *FlagSet) StringToInt64S(name, shorthand string, value map[string]int64, usage string) *map[string]int64

StringToInt64S is like StringToInt64, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) StringToInt64Var added in v1.1.3

func (f *FlagSet) StringToInt64Var(p *map[string]int64, name string, value map[string]int64, usage string)

StringToInt64Var defines a string flag with specified name, default value, and usage string. The argument p point64s to a map[string]int64 variable in which to store the values of the multiple flags. The value of each argument will not try to be separated by comma

func (*FlagSet) StringToInt64VarP added in v1.1.3

func (f *FlagSet) StringToInt64VarP(p *map[string]int64, name, shorthand string, value map[string]int64, usage string)

StringToInt64VarP is like StringToInt64Var, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) StringToInt64VarS added in v1.1.3

func (f *FlagSet) StringToInt64VarS(p *map[string]int64, name, shorthand string, value map[string]int64, usage string)

StringToInt64VarS is like StringToInt64Var, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) StringToIntP added in v1.0.3

func (f *FlagSet) StringToIntP(name, shorthand string, value map[string]int, usage string) *map[string]int

StringToIntP is like StringToInt, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) StringToIntS added in v1.1.3

func (f *FlagSet) StringToIntS(name, shorthand string, value map[string]int, usage string) *map[string]int

StringToIntS is like StringToInt, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) StringToIntVar added in v1.0.3

func (f *FlagSet) StringToIntVar(p *map[string]int, name string, value map[string]int, usage string)

StringToIntVar defines a string flag with specified name, default value, and usage string. The argument p points to a map[string]int variable in which to store the values of the multiple flags. The value of each argument will not try to be separated by comma

func (*FlagSet) StringToIntVarP added in v1.0.3

func (f *FlagSet) StringToIntVarP(p *map[string]int, name, shorthand string, value map[string]int, usage string)

StringToIntVarP is like StringToIntVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) StringToIntVarS added in v1.1.3

func (f *FlagSet) StringToIntVarS(p *map[string]int, name, shorthand string, value map[string]int, usage string)

StringToIntVarS is like StringToIntVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) StringToString added in v1.0.3

func (f *FlagSet) StringToString(name string, value map[string]string, usage string) *map[string]string

StringToString defines a string flag with specified name, default value, and usage string. The return value is the address of a map[string]string variable that stores the value of the flag. The value of each argument will not try to be separated by comma

func (*FlagSet) StringToStringP added in v1.0.3

func (f *FlagSet) StringToStringP(name, shorthand string, value map[string]string, usage string) *map[string]string

StringToStringP is like StringToString, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) StringToStringS added in v1.1.3

func (f *FlagSet) StringToStringS(name, shorthand string, value map[string]string, usage string) *map[string]string

StringToStringS is like StringToString, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) StringToStringVar added in v1.0.3

func (f *FlagSet) StringToStringVar(p *map[string]string, name string, value map[string]string, usage string)

StringToStringVar defines a string flag with specified name, default value, and usage string. The argument p points to a map[string]string variable in which to store the values of the multiple flags. The value of each argument will not try to be separated by comma

func (*FlagSet) StringToStringVarP added in v1.0.3

func (f *FlagSet) StringToStringVarP(p *map[string]string, name, shorthand string, value map[string]string, usage string)

StringToStringVarP is like StringToStringVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) StringToStringVarS added in v1.1.3

func (f *FlagSet) StringToStringVarS(p *map[string]string, name, shorthand string, value map[string]string, usage string)

StringToStringVarS is like StringToStringVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) StringVar

func (f *FlagSet) StringVar(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) StringVarP

func (f *FlagSet) StringVarP(p *string, name, shorthand string, value string, usage string)

StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) StringVarS added in v1.1.3

func (f *FlagSet) StringVarS(p *string, name, shorthand string, value string, usage string)

StringVarS is like StringVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Uint

func (f *FlagSet) Uint(name string, value uint, usage string) *uint

Uint defines a uint flag with specified name, default value, and usage string. The return value is the address of a uint variable that stores the value of the flag.

func (*FlagSet) Uint16

func (f *FlagSet) Uint16(name string, value uint16, usage string) *uint16

Uint16 defines a uint flag with specified name, default value, and usage string. The return value is the address of a uint variable that stores the value of the flag.

func (*FlagSet) Uint16P

func (f *FlagSet) Uint16P(name, shorthand string, value uint16, usage string) *uint16

Uint16P is like Uint16, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Uint16S added in v1.1.3

func (f *FlagSet) Uint16S(name, shorthand string, value uint16, usage string) *uint16

Uint16S is like Uint16, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Uint16Slice added in v1.1.3

func (f *FlagSet) Uint16Slice(name string, value []uint16, usage string) *[]uint16

Uint16Slice defines a []uint16 flag with specified name, default value, and usage string. The return value is the address of a []uint16 variable that stores the value of the flag.

func (*FlagSet) Uint16SliceP added in v1.1.3

func (f *FlagSet) Uint16SliceP(name, shorthand string, value []uint16, usage string) *[]uint16

Uint16SliceP is like Uint16Slice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Uint16SliceS added in v1.1.3

func (f *FlagSet) Uint16SliceS(name, shorthand string, value []uint16, usage string) *[]uint16

Uint16SliceS is like Uint16Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Uint16SliceVar added in v1.1.3

func (f *FlagSet) Uint16SliceVar(p *[]uint16, name string, value []uint16, usage string)

Uint16SliceVar defines a uint16Slice flag with specified name, default value, and usage string. The argument p pouints to a []uint16 variable in which to store the value of the flag.

func (*FlagSet) Uint16SliceVarP added in v1.1.3

func (f *FlagSet) Uint16SliceVarP(p *[]uint16, name, shorthand string, value []uint16, usage string)

Uint16SliceVarP is like Uint16SliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Uint16SliceVarS added in v1.1.3

func (f *FlagSet) Uint16SliceVarS(p *[]uint16, name, shorthand string, value []uint16, usage string)

Uint16SliceVarS is like Uint16SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Uint16Var

func (f *FlagSet) Uint16Var(p *uint16, name string, value uint16, usage string)

Uint16Var 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) Uint16VarP

func (f *FlagSet) Uint16VarP(p *uint16, name, shorthand string, value uint16, usage string)

Uint16VarP is like Uint16Var, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Uint16VarS added in v1.1.3

func (f *FlagSet) Uint16VarS(p *uint16, name, shorthand string, value uint16, usage string)

Uint16VarS is like Uint16Var, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Uint32

func (f *FlagSet) Uint32(name string, value uint32, usage string) *uint32

Uint32 defines a uint32 flag with specified name, default value, and usage string. The return value is the address of a uint32 variable that stores the value of the flag.

func (*FlagSet) Uint32P

func (f *FlagSet) Uint32P(name, shorthand string, value uint32, usage string) *uint32

Uint32P is like Uint32, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Uint32S added in v1.1.3

func (f *FlagSet) Uint32S(name, shorthand string, value uint32, usage string) *uint32

Uint32S is like Uint32, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Uint32Slice added in v1.1.3

func (f *FlagSet) Uint32Slice(name string, value []uint32, usage string) *[]uint32

Uint32Slice defines a []uint32 flag with specified name, default value, and usage string. The return value is the address of a []uint32 variable that stores the value of the flag.

func (*FlagSet) Uint32SliceP added in v1.1.3

func (f *FlagSet) Uint32SliceP(name, shorthand string, value []uint32, usage string) *[]uint32

Uint32SliceP is like Uint32Slice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Uint32SliceS added in v1.1.3

func (f *FlagSet) Uint32SliceS(name, shorthand string, value []uint32, usage string) *[]uint32

Uint32SliceS is like Uint32Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Uint32SliceVar added in v1.1.3

func (f *FlagSet) Uint32SliceVar(p *[]uint32, name string, value []uint32, usage string)

Uint32SliceVar defines a uint32Slice flag with specified name, default value, and usage string. The argument p pouints to a []uint32 variable in which to store the value of the flag.

func (*FlagSet) Uint32SliceVarP added in v1.1.3

func (f *FlagSet) Uint32SliceVarP(p *[]uint32, name, shorthand string, value []uint32, usage string)

Uint32SliceVarP is like Uint32SliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Uint32SliceVarS added in v1.1.3

func (f *FlagSet) Uint32SliceVarS(p *[]uint32, name, shorthand string, value []uint32, usage string)

Uint32SliceVarS is like Uint32SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Uint32Var

func (f *FlagSet) Uint32Var(p *uint32, name string, value uint32, usage string)

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

func (*FlagSet) Uint32VarP

func (f *FlagSet) Uint32VarP(p *uint32, name, shorthand string, value uint32, usage string)

Uint32VarP is like Uint32Var, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Uint32VarS added in v1.1.3

func (f *FlagSet) Uint32VarS(p *uint32, name, shorthand string, value uint32, usage string)

Uint32VarS is like Uint32Var, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Uint64

func (f *FlagSet) Uint64(name string, value uint64, usage string) *uint64

Uint64 defines a uint64 flag with specified name, default value, and usage string. The return value is the address of a uint64 variable that stores the value of the flag.

func (*FlagSet) Uint64P

func (f *FlagSet) Uint64P(name, shorthand string, value uint64, usage string) *uint64

Uint64P is like Uint64, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Uint64S added in v1.1.3

func (f *FlagSet) Uint64S(name, shorthand string, value uint64, usage string) *uint64

Uint64S is like Uint64, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Uint64Slice added in v1.1.3

func (f *FlagSet) Uint64Slice(name string, value []uint64, usage string) *[]uint64

Uint64Slice defines a []uint64 flag with specified name, default value, and usage string. The return value is the address of a []uint64 variable that stores the value of the flag.

func (*FlagSet) Uint64SliceP added in v1.1.3

func (f *FlagSet) Uint64SliceP(name, shorthand string, value []uint64, usage string) *[]uint64

Uint64SliceP is like Uint64Slice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Uint64SliceS added in v1.1.3

func (f *FlagSet) Uint64SliceS(name, shorthand string, value []uint64, usage string) *[]uint64

Uint64SliceS is like Uint64Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Uint64SliceVar added in v1.1.3

func (f *FlagSet) Uint64SliceVar(p *[]uint64, name string, value []uint64, usage string)

Uint64SliceVar defines a uint64Slice flag with specified name, default value, and usage string. The argument p pouints to a []uint64 variable in which to store the value of the flag.

func (*FlagSet) Uint64SliceVarP added in v1.1.3

func (f *FlagSet) Uint64SliceVarP(p *[]uint64, name, shorthand string, value []uint64, usage string)

Uint64SliceVarP is like Uint64SliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Uint64SliceVarS added in v1.1.3

func (f *FlagSet) Uint64SliceVarS(p *[]uint64, name, shorthand string, value []uint64, usage string)

Uint64SliceVarS is like Uint64SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Uint64Var

func (f *FlagSet) Uint64Var(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) Uint64VarP

func (f *FlagSet) Uint64VarP(p *uint64, name, shorthand string, value uint64, usage string)

Uint64VarP is like Uint64Var, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Uint64VarS added in v1.1.3

func (f *FlagSet) Uint64VarS(p *uint64, name, shorthand string, value uint64, usage string)

Uint64VarS is like Uint64Var, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Uint8

func (f *FlagSet) Uint8(name string, value uint8, usage string) *uint8

Uint8 defines a uint8 flag with specified name, default value, and usage string. The return value is the address of a uint8 variable that stores the value of the flag.

func (*FlagSet) Uint8P

func (f *FlagSet) Uint8P(name, shorthand string, value uint8, usage string) *uint8

Uint8P is like Uint8, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Uint8S added in v1.1.3

func (f *FlagSet) Uint8S(name, shorthand string, value uint8, usage string) *uint8

Uint8S is like Uint8, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Uint8Slice added in v1.1.3

func (f *FlagSet) Uint8Slice(name string, value []uint8, usage string) *[]uint8

Uint8Slice defines a []uint8 flag with specified name, default value, and usage string. The return value is the address of a []uint8 variable that stores the value of the flag.

func (*FlagSet) Uint8SliceP added in v1.1.3

func (f *FlagSet) Uint8SliceP(name, shorthand string, value []uint8, usage string) *[]uint8

Uint8SliceP is like Uint8Slice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Uint8SliceS added in v1.1.3

func (f *FlagSet) Uint8SliceS(name, shorthand string, value []uint8, usage string) *[]uint8

Uint8SliceS is like Uint8Slice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Uint8SliceVar added in v1.1.3

func (f *FlagSet) Uint8SliceVar(p *[]uint8, name string, value []uint8, usage string)

Uint8SliceVar defines a uint8Slice flag with specified name, default value, and usage string. The argument p pouints to a []uint8 variable in which to store the value of the flag.

func (*FlagSet) Uint8SliceVarP added in v1.1.3

func (f *FlagSet) Uint8SliceVarP(p *[]uint8, name, shorthand string, value []uint8, usage string)

Uint8SliceVarP is like Uint8SliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Uint8SliceVarS added in v1.1.3

func (f *FlagSet) Uint8SliceVarS(p *[]uint8, name, shorthand string, value []uint8, usage string)

Uint8SliceVarS is like Uint8SliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Uint8Var

func (f *FlagSet) Uint8Var(p *uint8, name string, value uint8, usage string)

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

func (*FlagSet) Uint8VarP

func (f *FlagSet) Uint8VarP(p *uint8, name, shorthand string, value uint8, usage string)

Uint8VarP is like Uint8Var, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) Uint8VarS added in v1.1.3

func (f *FlagSet) Uint8VarS(p *uint8, name, shorthand string, value uint8, usage string)

Uint8VarS is like Uint8Var, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) UintP

func (f *FlagSet) UintP(name, shorthand string, value uint, usage string) *uint

UintP is like Uint, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) UintS added in v1.1.3

func (f *FlagSet) UintS(name, shorthand string, value uint, usage string) *uint

UintS is like Uint, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) UintSlice

func (f *FlagSet) UintSlice(name string, value []uint, usage string) *[]uint

UintSlice defines a []uint flag with specified name, default value, and usage string. The return value is the address of a []uint variable that stores the value of the flag.

func (*FlagSet) UintSliceP

func (f *FlagSet) UintSliceP(name, shorthand string, value []uint, usage string) *[]uint

UintSliceP is like UintSlice, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) UintSliceS added in v1.1.3

func (f *FlagSet) UintSliceS(name, shorthand string, value []uint, usage string) *[]uint

UintSliceS is like UintSlice, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) UintSliceVar

func (f *FlagSet) UintSliceVar(p *[]uint, name string, value []uint, usage string)

UintSliceVar defines a uintSlice 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) UintSliceVarP

func (f *FlagSet) UintSliceVarP(p *[]uint, name, shorthand string, value []uint, usage string)

UintSliceVarP is like UintSliceVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) UintSliceVarS added in v1.1.3

func (f *FlagSet) UintSliceVarS(p *[]uint, name, shorthand string, value []uint, usage string)

UintSliceVarS is like UintSliceVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) UintVar

func (f *FlagSet) UintVar(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) UintVarP

func (f *FlagSet) UintVarP(p *uint, name, shorthand string, value uint, usage string)

UintVarP is like UintVar, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) UintVarS added in v1.1.3

func (f *FlagSet) UintVarS(p *uint, name, shorthand string, value uint, usage string)

UintVarS is like UintVar, but accepts a shorthand letter that can be used after a single dash, alone.

func (*FlagSet) Var

func (f *FlagSet) Var(value 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 Value, which typically holds a user-defined implementation of Value. For instance, the caller could create a flag that turns a comma-separated string into a slice of strings by giving the slice the methods of Value; in particular, Set would decompose the comma-separated string into the slice.

func (*FlagSet) VarP

func (f *FlagSet) VarP(value Value, name, shorthand, usage string)

VarP is like Var, but accepts a shorthand letter that can be used after a single dash.

func (*FlagSet) VarPF

func (f *FlagSet) VarPF(value Value, name, shorthand, usage string) *Flag

VarPF is like VarP, but returns the flag created

func (*FlagSet) VarS added in v1.1.3

func (f *FlagSet) VarS(value Value, name string, shorthand string, usage string)

VarS is like Var, but accepts a shorthand letter to be used after a single dash, alone.

func (*FlagSet) VarSF added in v1.1.3

func (f *FlagSet) VarSF(value Value, name string, shorthand string, usage string) *Flag

VarSF is like VarS, but returns the flag created

func (*FlagSet) Visit

func (f *FlagSet) Visit(fn func(*Flag))

Visit visits the flags in lexicographical order or in primordial order if f.SortFlags is false, calling fn for each. It visits only those flags that have been set.

func (*FlagSet) VisitAll

func (f *FlagSet) VisitAll(fn func(*Flag))

VisitAll visits the flags in lexicographical order or in primordial order if f.SortFlags is false, calling fn for each. It visits all flags, even those not set.

type NormalizedName

type NormalizedName string

NormalizedName is a flag name that has been normalized according to rules for the FlagSet (e.g. making '-' and '_' equivalent).

type ParseErrorsWhitelist added in v1.0.1

type ParseErrorsWhitelist struct {
	// UnknownFlags will ignore unknown flags errors and continue parsing rest of the flags
	// See GetUnknownFlags to retrieve collected unknowns.
	UnknownFlags bool
}

ParseErrorsWhitelist defines the parsing errors that can be ignored

type SliceValue added in v1.1.3

type SliceValue interface {
	// Append adds the specified value to the end of the flag value list.
	Append(string) error
	// Replace will fully overwrite any data currently in the flag value list.
	Replace([]string) error
	// GetSlice returns the flag value list as an array of strings.
	GetSlice() []string
}

SliceValue is a secondary interface to all flags which hold a list of values. This allows full control over the value of list flags, and avoids complicated marshalling and unmarshalling to csv.

type Value

type Value interface {
	String() string
	Set(string) error
	Type() string
}

Value is the interface to the dynamic value stored in a flag. (The default value is represented as a string.)

Jump to

Keyboard shortcuts

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