{"modulePath":"github.com/hyperhq/hypercli","version":"v1.10.16","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package mflag\n\n## Constants\n\n```go\nconst (\n\tExact nArgRequirementType = iota\n\tMax\n\tMin\n)\n```\nIndicator used to pass to BadArgs function\n\n## Variables\n\n```go\nvar CommandLine = NewFlagSet(os.Args[0], ExitOnError)\n```\nCommandLine is the default set of command-line flags, parsed from os.Args. The top-level functions such as BoolVar, Arg, and on are wrappers for the methods of CommandLine.\n\n```go\nvar ErrHelp = errors.New(\"flag: help requested\")\n```\nErrHelp is the error returned if the flag -help is invoked but no such flag is defined.\n\n```go\nvar ErrRetry = errors.New(\"flag: retry\")\n```\nErrRetry is the error returned if you need to try letter by letter\n\n```go\nvar ShortUsage = func() {\n\tfmt.Fprintf(CommandLine.output, \"Usage of %s:\\n\", os.Args[0])\n}\n```\nShortUsage prints to standard error a usage message documenting the standard command layout The function is a variable that may be changed to point to a custom function.\n\n```go\nvar Usage = func() {\n\tfmt.Fprintf(CommandLine.Out(), \"Usage of %s:\\n\", os.Args[0])\n\tPrintDefaults()\n}\n```\nUsage 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.\n\n## Functions\n\n```go\nfunc Arg(i int) string\n```\nArg returns the i'th command-line argument.  Arg(0) is the first remaining argument after flags have been processed.\n\n```go\nfunc Args() []string\n```\nArgs returns the non-flag command-line arguments.\n\n```go\nfunc Bool(names []string, value bool, usage string) *bool\n```\nBool 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.\n\n```go\nfunc BoolVar(p *bool, names []string, value bool, usage string)\n```\nBoolVar 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.\n\n```go\nfunc Duration(names []string, value time.Duration, usage string) *time.Duration\n```\nDuration 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.\n\n```go\nfunc DurationVar(p *time.Duration, names []string, value time.Duration, usage string)\n```\nDurationVar 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.\n\n```go\nfunc Float64(names []string, value float64, usage string) *float64\n```\nFloat64 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.\n\n```go\nfunc Float64Var(p *float64, names []string, value float64, usage string)\n```\nFloat64Var 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.\n\n```go\nfunc Int(names []string, value int, usage string) *int\n```\nInt 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.\n\n```go\nfunc Int64(names []string, value int64, usage string) *int64\n```\nInt64 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.\n\n```go\nfunc Int64Var(p *int64, names []string, value int64, usage string)\n```\nInt64Var 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.\n\n```go\nfunc IntVar(p *int, names []string, value int, usage string)\n```\nIntVar 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.\n\n```go\nfunc IsSet(name string) bool\n```\nIsSet indicates whether the specified flag was specified at all on the cmd line.\n\n```go\nfunc Merge(dest *FlagSet, flagsets ...*FlagSet) error\n```\nMerge is an helper function that merges n FlagSets into a single dest FlagSet In case of name collision between the flagsets it will apply the destination FlagSet's errorHandling behavior.\n\n```go\nfunc NArg() int\n```\nNArg is the number of arguments remaining after flags have been processed.\n\n```go\nfunc NFlag() int\n```\nNFlag returns the number of command-line flags that have been set.\n\n```go\nfunc Parse()\n```\nParse 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.\n\n```go\nfunc Parsed() bool\n```\nParsed returns true if the command-line flags have been parsed.\n\n```go\nfunc PrintDefaults()\n```\nPrintDefaults prints to standard error the default values of all defined command-line flags.\n\n```go\nfunc Set(name, value string) error\n```\nSet sets the value of the named command-line flag.\n\n```go\nfunc String(names []string, value string, usage string) *string\n```\nString 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.\n\n```go\nfunc StringVar(p *string, names []string, value string, usage string)\n```\nStringVar 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.\n\n```go\nfunc Uint(names []string, value uint, usage string) *uint\n```\nUint 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.\n\n```go\nfunc Uint16(names []string, value uint16, usage string) *uint16\n```\nUint16 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.\n\n```go\nfunc Uint16Var(p *uint16, names []string, value uint16, usage string)\n```\nUint16Var defines a uint16 flag with specified name, default value, and usage string. The argument p points to a uint16 variable in which to store the value of the flag.\n\n```go\nfunc Uint64(names []string, value uint64, usage string) *uint64\n```\nUint64 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.\n\n```go\nfunc Uint64Var(p *uint64, names []string, value uint64, usage string)\n```\nUint64Var 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.\n\n```go\nfunc UintVar(p *uint, names []string, value uint, usage string)\n```\nUintVar 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.\n\n```go\nfunc Var(value Value, names []string, usage string)\n```\nVar 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.\n\n```go\nfunc Visit(fn func(*Flag))\n```\nVisit visits the command-line flags in lexicographical order, calling fn for each.  It visits only those flags that have been set.\n\n```go\nfunc VisitAll(fn func(*Flag))\n```\nVisitAll visits the command-line flags in lexicographical order, calling fn for each.  It visits all flags, even those not set.\n\n## Types\n\n```go\ntype ErrorHandling int\n```\nErrorHandling defines how to handle flag parsing errors.\n\n```go\nconst (\n\tContinueOnError ErrorHandling = iota\n\tExitOnError\n\tPanicOnError\n)\n```\nErrorHandling strategies available when a flag parsing error occurs\n\n```go\ntype Flag struct {\n\tNames    []string // name as it appears on command line\n\tUsage    string   // help message\n\tValue    Value    // value as set\n\tDefValue string   // default value (as text); for usage message\n}\n```\nA Flag represents the state of a flag.\n\n```go\nfunc Lookup(name string) *Flag\n```\nLookup returns the Flag structure of the named command-line flag, returning nil if none exists.\n\n```go\ntype FlagSet struct {\n\t// Usage is the function called when an error occurs while parsing flags.\n\t// The field is a function (not a method) that may be changed to point to\n\t// a custom error handler.\n\tUsage      func()\n\tShortUsage func()\n\t// contains filtered or unexported fields\n}\n```\nA FlagSet represents a set of defined flags.  The zero value of a FlagSet has no name and has ContinueOnError error handling.\n\n```go\nfunc NewFlagSet(name string, errorHandling ErrorHandling) *FlagSet\n```\nNewFlagSet returns a new, empty flag set with the specified name and error handling property.\n\n```go\nfunc (fs *FlagSet) Arg(i int) string\n```\nArg returns the i'th argument.  Arg(0) is the first remaining argument after flags have been processed.\n\n```go\nfunc (fs *FlagSet) Args() []string\n```\nArgs returns the non-flag arguments.\n\n```go\nfunc (fs *FlagSet) Bool(names []string, value bool, usage string) *bool\n```\nBool 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.\n\n```go\nfunc (fs *FlagSet) BoolVar(p *bool, names []string, value bool, usage string)\n```\nBoolVar 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.\n\n```go\nfunc (fs *FlagSet) CheckArgs() (message string)\n```\nCheckArgs uses the requirements set by FlagSet.Require() to validate the number of arguments. If the requirements are not met, an error message string is returned.\n\n```go\nfunc (fs *FlagSet) Duration(names []string, value time.Duration, usage string) *time.Duration\n```\nDuration 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.\n\n```go\nfunc (fs *FlagSet) DurationVar(p *time.Duration, names []string, value time.Duration, usage string)\n```\nDurationVar 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.\n\n```go\nfunc (fs *FlagSet) FlagCount() int\n```\nFlagCount returns the number of flags that have been defined.\n\n```go\nfunc (fs *FlagSet) FlagCountUndeprecated() int\n```\nFlagCountUndeprecated returns the number of undeprecated flags that have been defined.\n\n```go\nfunc (fs *FlagSet) Float64(names []string, value float64, usage string) *float64\n```\nFloat64 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.\n\n```go\nfunc (fs *FlagSet) Float64Var(p *float64, names []string, value float64, usage string)\n```\nFloat64Var 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.\n\n```go\nfunc (fs *FlagSet) Init(name string, errorHandling ErrorHandling)\n```\nInit 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.\n\n```go\nfunc (fs *FlagSet) Int(names []string, value int, usage string) *int\n```\nInt 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.\n\n```go\nfunc (fs *FlagSet) Int64(names []string, value int64, usage string) *int64\n```\nInt64 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.\n\n```go\nfunc (fs *FlagSet) Int64Var(p *int64, names []string, value int64, usage string)\n```\nInt64Var 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.\n\n```go\nfunc (fs *FlagSet) IntVar(p *int, names []string, value int, usage string)\n```\nIntVar 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.\n\n```go\nfunc (fs *FlagSet) IsEmpty() bool\n```\nIsEmpty reports if the FlagSet is actually empty.\n\n```go\nfunc (fs *FlagSet) IsSet(name string) bool\n```\nIsSet indicates whether the specified flag is set in the given FlagSet\n\n```go\nfunc (fs *FlagSet) Lookup(name string) *Flag\n```\nLookup returns the Flag structure of the named flag, returning nil if none exists.\n\n```go\nfunc (fs *FlagSet) NArg() int\n```\nNArg is the number of arguments remaining after flags have been processed.\n\n```go\nfunc (fs *FlagSet) NFlag() int\n```\nNFlag returns the number of flags that have been set.\n\n```go\nfunc (fs *FlagSet) Name() string\n```\nName returns the name of the FlagSet.\n\n```go\nfunc (fs *FlagSet) Out() io.Writer\n```\nOut returns the destination for usage and error messages.\n\n```go\nfunc (fs *FlagSet) Parse(arguments []string) error\n```\nParse 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.\n\n```go\nfunc (fs *FlagSet) ParseFlags(args []string, withHelp bool) error\n```\nParseFlags is a utility function that adds a help flag if withHelp is true, calls fs.Parse(args) and prints a relevant error message if there are incorrect number of arguments. It returns error only if error handling is set to ContinueOnError and parsing fails. If error handling is set to ExitOnError, it's safe to ignore the return value.\n\n```go\nfunc (fs *FlagSet) Parsed() bool\n```\nParsed reports whether fs.Parse has been called.\n\n```go\nfunc (fs *FlagSet) PrintDefaults()\n```\nPrintDefaults prints, to standard error unless configured otherwise, the default values of all defined flags in the set.\n\n```go\nfunc (fs *FlagSet) ReportError(str string, withHelp bool)\n```\nReportError is a utility method that prints a user-friendly message containing the error that occurred during parsing and a suggestion to get help\n\n```go\nfunc (fs *FlagSet) Require(nArgRequirementType nArgRequirementType, nArg int)\n```\nRequire adds a requirement about the number of arguments for the FlagSet. The first parameter can be Exact, Max, or Min to respectively specify the exact, the maximum, or the minimal number of arguments required. The actual check is done in FlagSet.CheckArgs().\n\n```go\nfunc (fs *FlagSet) Set(name, value string) error\n```\nSet sets the value of the named flag.\n\n```go\nfunc (fs *FlagSet) SetOutput(output io.Writer)\n```\nSetOutput sets the destination for usage and error messages. If output is nil, os.Stderr is used.\n\n```go\nfunc (fs *FlagSet) String(names []string, value string, usage string) *string\n```\nString 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.\n\n```go\nfunc (fs *FlagSet) StringVar(p *string, names []string, value string, usage string)\n```\nStringVar 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.\n\n```go\nfunc (fs *FlagSet) Uint(names []string, value uint, usage string) *uint\n```\nUint 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.\n\n```go\nfunc (fs *FlagSet) Uint16(names []string, value uint16, usage string) *uint16\n```\nUint16 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.\n\n```go\nfunc (fs *FlagSet) Uint16Var(p *uint16, names []string, value uint16, usage string)\n```\nUint16Var defines a uint16 flag with specified name, default value, and usage string. The argument p points to a uint16 variable in which to store the value of the flag.\n\n```go\nfunc (fs *FlagSet) Uint64(names []string, value uint64, usage string) *uint64\n```\nUint64 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.\n\n```go\nfunc (fs *FlagSet) Uint64Var(p *uint64, names []string, value uint64, usage string)\n```\nUint64Var 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.\n\n```go\nfunc (fs *FlagSet) UintVar(p *uint, names []string, value uint, usage string)\n```\nUintVar 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.\n\n```go\nfunc (fs *FlagSet) Var(value Value, names []string, usage string)\n```\nVar 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.\n\n```go\nfunc (fs *FlagSet) Visit(fn func(*Flag))\n```\nVisit visits the flags in lexicographical order, calling fn for each. It visits only those flags that have been set.\n\n```go\nfunc (fs *FlagSet) VisitAll(fn func(*Flag))\n```\nVisitAll visits the flags in lexicographical order, calling fn for each. It visits all flags, even those not set.\n\n```go\ntype Getter interface {\n\tValue\n\tGet() interface{}\n}\n```\nGetter is an interface that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.\n\n```go\ntype Value interface {\n\tString() string\n\tSet(string) error\n}\n```\nValue is the interface to the dynamic value stored in a flag. (The default value is represented as a string.)\n\nIf a Value has an IsBoolFlag() bool method returning true, the command-line parser makes -name equivalent to -name=true rather than using the next command-line argument.\n\n","path":"github.com/hyperhq/hypercli/pkg/mflag","name":"mflag","synopsis":"","isRedistributable":true}
