flaggy: github.com/integrii/flaggy Index | Examples | Files

package flaggy

import "github.com/integrii/flaggy"

Package flaggy is a input flag parsing package that supports recursive subcommands, positional values, and any-position flags without unnecessary complexeties.

For a getting started tutorial and full feature list, check out the readme at https://github.com/integrii/flaggy.

Example shows how to add string flags in your program.

Code:

// Simulate some input from the CLI.  Don't do this in your program.
flaggy.ResetParser()
os.Args = []string{"binaryName", "-f", "flagName"}

// Imagine the following program usage:
//
// ./binaryName -f flagName
// or
// ./binaryName --flag=flagName

// add a string flag at the global level
var stringFlag string
flaggy.String(&stringFlag, "f", "flag", "A test string flag")

// Parse the input arguments from the OS (os.Args)
flaggy.Parse()

// see if our flag was set properly
if stringFlag == "flagName" {
    fmt.Println("Flag set to:", stringFlag)
}

Output:

Flag set to: flagName

Index

Examples

Package Files

argumentParser.go flag.go help.go helpValues.go main.go parser.go positionalValue.go subCommand.go

Variables

var DebugMode bool

DebugMode indicates that debug output should be enabled

var DefaultHelpTemplate = defaultHelpTemplate

DefaultHelpTemplate is the help template that will be used for newly created subcommands and commands

var PanicInsteadOfExit bool

PanicInsteadOfExit is used when running tests

var TrailingArguments []string

TrailingArguments holds trailing arguments in the main parser after parsing has been run.

func AddPositionalValue Uses

func AddPositionalValue(assignmentVar *string, name string, relativePosition int, required bool, description string)

AddPositionalValue adds a positional value to the main parser at the global context

func AttachSubcommand Uses

func AttachSubcommand(subcommand *Subcommand, relativePosition int)

AttachSubcommand adds a subcommand for parsing

func Bool Uses

func Bool(assignmentVar *bool, shortName string, longName string, description string)

Bool adds a new bool flag

ExampleBoolFlag shows how to global bool flags in your program.

Code:

// Simulate some input from the CLI.  Don't do these two lines in your program.
flaggy.ResetParser()
os.Args = []string{"binaryName", "-f"}

// Imagine the following program usage:
//
// ./binaryName -f
// or
// ./binaryName --flag=true

// add a bool flag at the global level
var boolFlag bool
flaggy.Bool(&boolFlag, "f", "flag", "A test bool flag")

// Parse the input arguments from the OS (os.Args)
flaggy.Parse()

// see if our flag was set properly
if boolFlag == true {
    fmt.Println("Flag set")
}

Output:

Flag set

func BoolSlice Uses

func BoolSlice(assignmentVar *[]bool, shortName string, longName string, description string)

BoolSlice adds a new slice of bools flag Specify the flag multiple times to fill the slice

func ByteSlice Uses

func ByteSlice(assignmentVar *[]byte, shortName string, longName string, description string)

ByteSlice adds a new slice of bytes flag Specify the flag multiple times to fill the slice. Takes hex as input.

func Duration Uses

func Duration(assignmentVar *time.Duration, shortName string, longName string, description string)

Duration adds a new time.Duration flag. Input format is described in time.ParseDuration(). Example values: 1h, 1h50m, 32s

func DurationSlice Uses

func DurationSlice(assignmentVar *[]time.Duration, shortName string, longName string, description string)

DurationSlice adds a new time.Duration flag. Input format is described in time.ParseDuration(). Example values: 1h, 1h50m, 32s Specify the flag multiple times to fill the slice.

func Float32 Uses

func Float32(assignmentVar *float32, shortName string, longName string, description string)

Float32 adds a new float32 flag.

func Float32Slice Uses

func Float32Slice(assignmentVar *[]float32, shortName string, longName string, description string)

Float32Slice adds a new float32 flag. Specify the flag multiple times to fill the slice.

func Float64 Uses

func Float64(assignmentVar *float64, shortName string, longName string, description string)

Float64 adds a new float64 flag.

func Float64Slice Uses

func Float64Slice(assignmentVar *[]float64, shortName string, longName string, description string)

Float64Slice adds a new float64 flag. Specify the flag multiple times to fill the slice.

func HardwareAddr Uses

func HardwareAddr(assignmentVar *net.HardwareAddr, shortName string, longName string, description string)

HardwareAddr adds a new net.HardwareAddr flag.

func HardwareAddrSlice Uses

func HardwareAddrSlice(assignmentVar *[]net.HardwareAddr, shortName string, longName string, description string)

HardwareAddrSlice adds a new net.HardwareAddr slice flag. Specify the flag multiple times to fill the slice.

func IP Uses

func IP(assignmentVar *net.IP, shortName string, longName string, description string)

IP adds a new net.IP flag.

func IPMask Uses

func IPMask(assignmentVar *net.IPMask, shortName string, longName string, description string)

IPMask adds a new net.IPMask flag. IPv4 Only.

func IPMaskSlice Uses

func IPMaskSlice(assignmentVar *[]net.IPMask, shortName string, longName string, description string)

IPMaskSlice adds a new net.HardwareAddr slice flag. IPv4 only. Specify the flag multiple times to fill the slice.

func IPSlice Uses

func IPSlice(assignmentVar *[]net.IP, shortName string, longName string, description string)

IPSlice adds a new int8 slice flag. Specify the flag multiple times to fill the slice.

func Int Uses

func Int(assignmentVar *int, shortName string, longName string, description string)

Int adds a new int flag

ExampleIntFlag shows how to global int flags in your program.

Code:

// Simulate some input from the CLI.  Don't do these two lines in your program.
flaggy.ResetParser()
os.Args = []string{"binaryName", "-f", "5"}

// Imagine the following program usage:
//
// ./binaryName -f 5
// or
// ./binaryName --flag=5

// add a int flag at the global level
var intFlag int
flaggy.Int(&intFlag, "f", "flag", "A test int flag")

// Parse the input arguments from the OS (os.Args)
flaggy.Parse()

// see if our flag was set properly
if intFlag == 5 {
    fmt.Println("Flag set to:", intFlag)
}

Output:

Flag set to: 5

func Int16 Uses

func Int16(assignmentVar *int16, shortName string, longName string, description string)

Int16 adds a new int16 flag

func Int16Slice Uses

func Int16Slice(assignmentVar *[]int16, shortName string, longName string, description string)

Int16Slice adds a new int16 slice flag. Specify the flag multiple times to fill the slice.

func Int32 Uses

func Int32(assignmentVar *int32, shortName string, longName string, description string)

Int32 adds a new int32 flag

func Int32Slice Uses

func Int32Slice(assignmentVar *[]int32, shortName string, longName string, description string)

Int32Slice adds a new int32 slice flag. Specify the flag multiple times to fill the slice.

func Int64 Uses

func Int64(assignmentVar *int64, shortName string, longName string, description string)

Int64 adds a new int64 flag

func Int64Slice Uses

func Int64Slice(assignmentVar *[]int64, shortName string, longName string, description string)

Int64Slice adds a new int64 slice flag. Specify the flag multiple times to fill the slice.

func Int8 Uses

func Int8(assignmentVar *int8, shortName string, longName string, description string)

Int8 adds a new int8 flag

func Int8Slice Uses

func Int8Slice(assignmentVar *[]int8, shortName string, longName string, description string)

Int8Slice adds a new int8 slice flag. Specify the flag multiple times to fill the slice.

func IntSlice Uses

func IntSlice(assignmentVar *[]int, shortName string, longName string, description string)

IntSlice adds a new int slice flag. Specify the flag multiple times to fill the slice.

func Parse Uses

func Parse()

Parse parses flags as requested in the default package parser

func ParseArgs Uses

func ParseArgs(args []string)

ParseArgs parses the passed args as if they were the arguments to the running binary. Targets the default main parser for the package.

func ResetParser Uses

func ResetParser()

ResetParser resets the default parser to a fresh instance. Uses the name of the binary executing as the program name by default.

func SetDescription Uses

func SetDescription(description string)

SetDescription sets the description of the default package command parser

func SetName Uses

func SetName(name string)

SetName sets the name of the default package command parser

func SetVersion Uses

func SetVersion(version string)

SetVersion sets the version of the default package command parser

func ShowHelp Uses

func ShowHelp(message string)

ShowHelp shows parser help

func ShowHelpAndExit Uses

func ShowHelpAndExit(message string)

ShowHelpAndExit shows parser help and exits with status code 2

func String Uses

func String(assignmentVar *string, shortName string, longName string, description string)

String adds a new string flag

func StringSlice Uses

func StringSlice(assignmentVar *[]string, shortName string, longName string, description string)

StringSlice adds a new slice of strings flag Specify the flag multiple times to fill the slice

func UInt Uses

func UInt(assignmentVar *uint, shortName string, longName string, description string)

UInt adds a new uint flag

func UInt16 Uses

func UInt16(assignmentVar *uint16, shortName string, longName string, description string)

UInt16 adds a new uint16 flag

func UInt16Slice Uses

func UInt16Slice(assignmentVar *[]uint16, shortName string, longName string, description string)

UInt16Slice adds a new uint16 slice flag. Specify the flag multiple times to fill the slice.

func UInt32 Uses

func UInt32(assignmentVar *uint32, shortName string, longName string, description string)

UInt32 adds a new uint32 flag

func UInt32Slice Uses

func UInt32Slice(assignmentVar *[]uint32, shortName string, longName string, description string)

UInt32Slice adds a new uint32 slice flag. Specify the flag multiple times to fill the slice.

func UInt64 Uses

func UInt64(assignmentVar *uint64, shortName string, longName string, description string)

UInt64 adds a new uint64 flag

func UInt64Slice Uses

func UInt64Slice(assignmentVar *[]uint64, shortName string, longName string, description string)

UInt64Slice adds a new uint64 slice flag. Specify the flag multiple times to fill the slice.

func UInt8 Uses

func UInt8(assignmentVar *uint8, shortName string, longName string, description string)

UInt8 adds a new uint8 flag

func UInt8Slice Uses

func UInt8Slice(assignmentVar *[]uint8, shortName string, longName string, description string)

UInt8Slice adds a new uint8 slice flag. Specify the flag multiple times to fill the slice.

func UIntSlice Uses

func UIntSlice(assignmentVar *[]uint, shortName string, longName string, description string)

UIntSlice adds a new uint slice flag. Specify the flag multiple times to fill the slice.

type ArgumentParser Uses

type ArgumentParser interface {
    SetValueForKey(key string, value string) (bool, error)
}

ArgumentParser represents a parser or subcommand

type Flag Uses

type Flag struct {
    ShortName   string
    LongName    string
    Description string

    Hidden        bool // indicates this flag should be hidden from help and suggestions
    AssignmentVar interface{}
    // contains filtered or unexported fields
}

Flag holds the base methods for all flag types

func (*Flag) HasName Uses

func (f *Flag) HasName(name string) bool

HasName indicates that this flag's short or long name matches the supplied name string

type Help Uses

type Help struct {
    Subcommands    []HelpSubcommand
    Positionals    []HelpPositional
    Flags          []HelpFlag
    UsageString    string
    CommandName    string
    PrependMessage string
    AppendMessage  string
    Message        string
    Description    string
}

Help represents the values needed to render a Help page

func (*Help) AddFlagToHelp Uses

func (h *Help) AddFlagToHelp(f HelpFlag)

AddFlagToHelp adds a flag to help output if it does not exist

func (*Help) ExtractValues Uses

func (h *Help) ExtractValues(p *Parser, message string)

ExtractValues extracts Help template values from a subcommand and its parent parser. The parser is required in order to detect default flag settings for help and version outut.

type HelpFlag Uses

type HelpFlag struct {
    ShortName    string
    LongName     string
    Description  string
    DefaultValue string
}

HelpFlag is used to template string flag Help output

type HelpPositional Uses

type HelpPositional struct {
    Name         string
    Description  string
    Required     bool
    Position     int
    DefaultValue string
}

HelpPositional is used to template positional Help output

type HelpSubcommand Uses

type HelpSubcommand struct {
    ShortName   string
    LongName    string
    Description string
    Position    int
}

HelpSubcommand is used to template subcommand Help output

type Parser Uses

type Parser struct {
    Subcommand
    Version                    string             // the optional version of the parser.
    ShowHelpWithHFlag          bool               // display help when -h or --help passed
    ShowVersionWithVersionFlag bool               // display the version when --version passed
    ShowHelpOnUnexpected       bool               // display help when an unexpected flag is passed
    TrailingArguments          []string           // everything after a -- is placed here
    HelpTemplate               *template.Template // template for Help output
    // contains filtered or unexported fields
}

Parser represents the set of vars and subcommands we are expecting from our input args, and the parser than handles them all.

var DefaultParser *Parser

DefaultParser is the default parser that is used with the package-level public functions

func NewParser Uses

func NewParser(name string) *Parser

NewParser creates a new ArgumentParser ready to parse inputs

func (*Parser) Parse Uses

func (p *Parser) Parse() error

Parse calculates all flags and subcommands

func (*Parser) ParseArgs Uses

func (p *Parser) ParseArgs(args []string) error

ParseArgs parses as if the passed args were the os.Args, but without the binary at the 0 position in the array. An error is returned if there is a low level issue converting flags to their proper type. No error is returned for invalid arguments or missing require subcommands.

func (*Parser) SetHelpTemplate Uses

func (p *Parser) SetHelpTemplate(tmpl string) error

SetHelpTemplate sets the go template this parser will use when rendering Help.

func (*Parser) ShowHelp Uses

func (p *Parser) ShowHelp()

ShowHelp shows Help without an error message

func (*Parser) ShowHelpAndExit Uses

func (p *Parser) ShowHelpAndExit(message string)

ShowHelpAndExit shows parser help and exits with status code 2

func (*Parser) ShowHelpWithMessage Uses

func (p *Parser) ShowHelpWithMessage(message string)

ShowHelpWithMessage shows the Help for this parser with an optional string error message as a header. The supplied subcommand will be the context of Help displayed to the user.

func (*Parser) ShowVersionAndExit Uses

func (p *Parser) ShowVersionAndExit()

ShowVersionAndExit shows the version of this parser

type PositionalValue Uses

type PositionalValue struct {
    Name          string // used in documentation only
    Description   string
    AssignmentVar *string // the var that will get this variable
    Position      int     // the position, not including switches, of this variable
    Required      bool    // this subcommand must always be specified
    Found         bool    // was this positional found during parsing?
    Hidden        bool    // indicates this positional value should be hidden from help
    // contains filtered or unexported fields
}

PositionalValue represents a value which is determined by its position relative to where a subcommand was detected.

ExamplePositionalValue shows how to add positional variables at the global level.

Code:

// Simulate some input from the CLI.  Don't do this in your program.
flaggy.ResetParser()
os.Args = []string{"binaryName", "positionalValue"}

// Imagine the following program usage:
//
// ./binaryName positionalValue

// add a bool flag at the global level
var stringVar string
flaggy.AddPositionalValue(&stringVar, "positionalVar", 1, false, "A test positional flag")

// Parse the input arguments from the OS (os.Args)
flaggy.Parse()

// see if our flag was set properly
if stringVar == "positionalValue" {
    fmt.Println("Flag set to", stringVar)
}

Output:

Flag set to positionalValue

type Subcommand Uses

type Subcommand struct {
    Name                  string
    ShortName             string
    Description           string
    Position              int // the position of this subcommand, not including flags
    Subcommands           []*Subcommand
    Flags                 []*Flag
    PositionalFlags       []*PositionalValue
    AdditionalHelpPrepend string // additional prepended message when Help is displayed
    AdditionalHelpAppend  string // additional appended message when Help is displayed
    Used                  bool   // indicates this subcommand was found and parsed
    Hidden                bool   // indicates this subcommand should be hidden from help
}

Subcommand represents a subcommand which contains a set of child subcommands along with a set of flags relevant to it. Parsing runs until a subcommand is detected by matching its name and position. Once a matching subcommand is found, the next set of parsing occurs within that matched subcommand.

ExampleSubcommand shows usage of subcommands in flaggy.

Code:

// Do not include the following two lines in your real program, it is for this
// example only:
flaggy.ResetParser()
os.Args = []string{"programName", "-v", "VariableHere", "subcommandName", "subcommandPositional", "--", "trailingVar"}

// Imagine the input to this program is as follows:
//
// ./programName subcommandName -v VariableHere subcommandPositional -- trailingVar
//   or
// ./programName subcommandName subcommandPositional --variable VariableHere -- trailingVar
//   or
// ./programName subcommandName --variable=VariableHere subcommandPositional -- trailingVar
//   or even
// ./programName subcommandName subcommandPositional -v=VariableHere -- trailingVar
//

// Create a new subcommand to attach flags and other subcommands to.  It must be attached
// to something before being used.
newSC := flaggy.NewSubcommand("subcommandName")

// Attach a string variable to the subcommand
var subcommandVariable string
newSC.String(&subcommandVariable, "v", "variable", "A test variable.")

var subcommandPositional string
newSC.AddPositionalValue(&subcommandPositional, "testPositionalVar", 1, false, "A test positional variable to a subcommand.")

// Attach the subcommand to the parser. This will panic if another
// positional value or subcommand is already present at the depth supplied.
// Later you can check if this command was used with a simple bool (newSC.Used).
flaggy.AttachSubcommand(newSC, 1)

// Parse the input arguments from the OS (os.Args)
flaggy.Parse()

// see if the subcommand was found during parsing:
if newSC.Used {
    // Do subcommand operations here
    fmt.Println("Subcommand used")

    // check the input on your subcommand variable
    if subcommandVariable == "VariableHere" {
        fmt.Println("Subcommand variable set correctly")
    }

    // Print the subcommand positional value
    fmt.Println("Subcommand Positional:", subcommandPositional)

    // Print the first trailing argument
    fmt.Println("Trailing variable 1:", flaggy.TrailingArguments[0])
}

Output:

Subcommand used
Subcommand variable set correctly
Subcommand Positional: subcommandPositional
Trailing variable 1: trailingVar

func NewSubcommand Uses

func NewSubcommand(name string) *Subcommand

NewSubcommand creates a new subcommand that can have flags or PositionalFlags added to it. The position starts with 1, not 0

func (*Subcommand) AddPositionalValue Uses

func (sc *Subcommand) AddPositionalValue(assignmentVar *string, name string, relativePosition int, required bool, description string)

AddPositionalValue adds a positional value to the subcommand. the relativePosition starts at 1 and is relative to the subcommand it belongs to

ExampleSubcommand_AddPositionalValue adds two levels of subcommands with a positional value on the second level one

Code:

// Simulate some input from the CLI.  Don't do this in your program.
flaggy.ResetParser()
os.Args = []string{"binaryName", "subcommandA", "subcommandB", "subcommandBPositionalValue"}

// Imagine the following program usage:
//
// ./binaryName subcommandA subcommandB subcommandBPositional
//

var subcommandBPositional string

// create a subcommand
subcommandA := flaggy.NewSubcommand("subcommandA")
// add the subcommand at relative position 1 within the default root parser
flaggy.AttachSubcommand(subcommandA, 1)

// create a second subcommand
subcommandB := flaggy.NewSubcommand("subcommandB")
// add the second subcommand to the first subcommand as a child at relative
// position 1
subcommandA.AttachSubcommand(subcommandB, 1)
// add a positional to the second subcommand with a relative position of 1
subcommandB.AddPositionalValue(&subcommandBPositional, "subcommandTestPositonalValue", 1, false, "A test positional input variable")

// Parse the input arguments from the OS (os.Args) using the default parser
flaggy.Parse()

// see if our flag was set properly
fmt.Println("Positional flag set to", subcommandBPositional)

Output:

Positional flag set to subcommandBPositionalValue

func (*Subcommand) AttachSubcommand Uses

func (sc *Subcommand) AttachSubcommand(newSC *Subcommand, relativePosition int)

AttachSubcommand adds a possible subcommand to the Parser.

func (*Subcommand) Bool Uses

func (sc *Subcommand) Bool(assignmentVar *bool, shortName string, longName string, description string)

Bool adds a new bool flag

func (*Subcommand) BoolSlice Uses

func (sc *Subcommand) BoolSlice(assignmentVar *[]bool, shortName string, longName string, description string)

BoolSlice adds a new slice of bools flag Specify the flag multiple times to fill the slice

func (*Subcommand) ByteSlice Uses

func (sc *Subcommand) ByteSlice(assignmentVar *[]byte, shortName string, longName string, description string)

ByteSlice adds a new slice of bytes flag Specify the flag multiple times to fill the slice. Takes hex as input.

func (*Subcommand) Duration Uses

func (sc *Subcommand) Duration(assignmentVar *time.Duration, shortName string, longName string, description string)

Duration adds a new time.Duration flag. Input format is described in time.ParseDuration(). Example values: 1h, 1h50m, 32s

func (*Subcommand) DurationSlice Uses

func (sc *Subcommand) DurationSlice(assignmentVar *[]time.Duration, shortName string, longName string, description string)

DurationSlice adds a new time.Duration flag. Input format is described in time.ParseDuration(). Example values: 1h, 1h50m, 32s Specify the flag multiple times to fill the slice.

func (*Subcommand) FlagExists Uses

func (sc *Subcommand) FlagExists(name string) bool

FlagExists lets you know if the flag name exists as either a short or long name in the (sub)command

func (*Subcommand) Float32 Uses

func (sc *Subcommand) Float32(assignmentVar *float32, shortName string, longName string, description string)

Float32 adds a new float32 flag.

func (*Subcommand) Float32Slice Uses

func (sc *Subcommand) Float32Slice(assignmentVar *[]float32, shortName string, longName string, description string)

Float32Slice adds a new float32 flag. Specify the flag multiple times to fill the slice.

func (*Subcommand) Float64 Uses

func (sc *Subcommand) Float64(assignmentVar *float64, shortName string, longName string, description string)

Float64 adds a new float64 flag.

func (*Subcommand) Float64Slice Uses

func (sc *Subcommand) Float64Slice(assignmentVar *[]float64, shortName string, longName string, description string)

Float64Slice adds a new float64 flag. Specify the flag multiple times to fill the slice.

func (*Subcommand) HardwareAddr Uses

func (sc *Subcommand) HardwareAddr(assignmentVar *net.HardwareAddr, shortName string, longName string, description string)

HardwareAddr adds a new net.HardwareAddr flag.

func (*Subcommand) HardwareAddrSlice Uses

func (sc *Subcommand) HardwareAddrSlice(assignmentVar *[]net.HardwareAddr, shortName string, longName string, description string)

HardwareAddrSlice adds a new net.HardwareAddr slice flag. Specify the flag multiple times to fill the slice.

func (*Subcommand) IP Uses

func (sc *Subcommand) IP(assignmentVar *net.IP, shortName string, longName string, description string)

IP adds a new net.IP flag.

func (*Subcommand) IPMask Uses

func (sc *Subcommand) IPMask(assignmentVar *net.IPMask, shortName string, longName string, description string)

IPMask adds a new net.IPMask flag. IPv4 Only.

func (*Subcommand) IPMaskSlice Uses

func (sc *Subcommand) IPMaskSlice(assignmentVar *[]net.IPMask, shortName string, longName string, description string)

IPMaskSlice adds a new net.HardwareAddr slice flag. IPv4 only. Specify the flag multiple times to fill the slice.

func (*Subcommand) IPSlice Uses

func (sc *Subcommand) IPSlice(assignmentVar *[]net.IP, shortName string, longName string, description string)

IPSlice adds a new int8 slice flag. Specify the flag multiple times to fill the slice.

func (*Subcommand) Int Uses

func (sc *Subcommand) Int(assignmentVar *int, shortName string, longName string, description string)

Int adds a new int flag

func (*Subcommand) Int16 Uses

func (sc *Subcommand) Int16(assignmentVar *int16, shortName string, longName string, description string)

Int16 adds a new int16 flag

func (*Subcommand) Int16Slice Uses

func (sc *Subcommand) Int16Slice(assignmentVar *[]int16, shortName string, longName string, description string)

Int16Slice adds a new int16 slice flag. Specify the flag multiple times to fill the slice.

func (*Subcommand) Int32 Uses

func (sc *Subcommand) Int32(assignmentVar *int32, shortName string, longName string, description string)

Int32 adds a new int32 flag

func (*Subcommand) Int32Slice Uses

func (sc *Subcommand) Int32Slice(assignmentVar *[]int32, shortName string, longName string, description string)

Int32Slice adds a new int32 slice flag. Specify the flag multiple times to fill the slice.

func (*Subcommand) Int64 Uses

func (sc *Subcommand) Int64(assignmentVar *int64, shortName string, longName string, description string)

Int64 adds a new int64 flag.

func (*Subcommand) Int64Slice Uses

func (sc *Subcommand) Int64Slice(assignmentVar *[]int64, shortName string, longName string, description string)

Int64Slice adds a new int64 slice flag. Specify the flag multiple times to fill the slice.

func (*Subcommand) Int8 Uses

func (sc *Subcommand) Int8(assignmentVar *int8, shortName string, longName string, description string)

Int8 adds a new int8 flag

func (*Subcommand) Int8Slice Uses

func (sc *Subcommand) Int8Slice(assignmentVar *[]int8, shortName string, longName string, description string)

Int8Slice adds a new int8 slice flag. Specify the flag multiple times to fill the slice.

func (*Subcommand) IntSlice Uses

func (sc *Subcommand) IntSlice(assignmentVar *[]int, shortName string, longName string, description string)

IntSlice adds a new int slice flag. Specify the flag multiple times to fill the slice.

func (*Subcommand) SetValueForKey Uses

func (sc *Subcommand) SetValueForKey(key string, value string) (bool, error)

SetValueForKey sets the value for the specified key. If setting a bool value, then send "true" or "false" as strings. The returned bool indicates that a value was set.

func (*Subcommand) String Uses

func (sc *Subcommand) String(assignmentVar *string, shortName string, longName string, description string)

String adds a new string flag

func (*Subcommand) StringSlice Uses

func (sc *Subcommand) StringSlice(assignmentVar *[]string, shortName string, longName string, description string)

StringSlice adds a new slice of strings flag Specify the flag multiple times to fill the slice

func (*Subcommand) UInt Uses

func (sc *Subcommand) UInt(assignmentVar *uint, shortName string, longName string, description string)

UInt adds a new uint flag

func (*Subcommand) UInt16 Uses

func (sc *Subcommand) UInt16(assignmentVar *uint16, shortName string, longName string, description string)

UInt16 adds a new uint16 flag

func (*Subcommand) UInt16Slice Uses

func (sc *Subcommand) UInt16Slice(assignmentVar *[]uint16, shortName string, longName string, description string)

UInt16Slice adds a new uint16 slice flag. Specify the flag multiple times to fill the slice.

func (*Subcommand) UInt32 Uses

func (sc *Subcommand) UInt32(assignmentVar *uint32, shortName string, longName string, description string)

UInt32 adds a new uint32 flag

func (*Subcommand) UInt32Slice Uses

func (sc *Subcommand) UInt32Slice(assignmentVar *[]uint32, shortName string, longName string, description string)

UInt32Slice adds a new uint32 slice flag. Specify the flag multiple times to fill the slice.

func (*Subcommand) UInt64 Uses

func (sc *Subcommand) UInt64(assignmentVar *uint64, shortName string, longName string, description string)

UInt64 adds a new uint64 flag

func (*Subcommand) UInt64Slice Uses

func (sc *Subcommand) UInt64Slice(assignmentVar *[]uint64, shortName string, longName string, description string)

UInt64Slice adds a new uint64 slice flag. Specify the flag multiple times to fill the slice.

func (*Subcommand) UInt8 Uses

func (sc *Subcommand) UInt8(assignmentVar *uint8, shortName string, longName string, description string)

UInt8 adds a new uint8 flag

func (*Subcommand) UInt8Slice Uses

func (sc *Subcommand) UInt8Slice(assignmentVar *[]uint8, shortName string, longName string, description string)

UInt8Slice adds a new uint8 slice flag. Specify the flag multiple times to fill the slice.

func (*Subcommand) UIntSlice Uses

func (sc *Subcommand) UIntSlice(assignmentVar *[]uint, shortName string, longName string, description string)

UIntSlice adds a new uint slice flag. Specify the flag multiple times to fill the slice.

Package flaggy imports 10 packages (graph) and is imported by 3 packages. Updated 2018-10-09. Refresh now. Tools for package owners.