flag

package
v0.0.0-...-fdaedd9 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: MIT Imports: 2 Imported by: 3

Documentation

Overview

Package flag provides types and functions to create and manage your command line applications

Package flag provides types and functions to create and manage your command line applications

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flag

type Flag struct {
	// Short is the short name of the flag
	Short string
	// Long is the long name of the flag
	Long string
	// Description holds information describing the
	// behavior of the flag can have
	Description string
	// Type is the value type of the flag
	Type argument.Type
	// Required is true when the user is required to
	// pass this flag in the command line
	Required bool
	// contains filtered or unexported fields
}

Flag type holds all information for a flag to be parsed on the command line

func (Flag) Is

func (f Flag) Is(arg string) bool

Is returns true if the argument name is present in the short or long name of the flag

func (Flag) Parsed

func (f Flag) Parsed() bool

Parsed return true if the flag is parsed

func (Flag) String

func (f Flag) String() string

String returns the flag as string format

func (Flag) Validate

func (f Flag) Validate() error

Validate validates if the flag definitions are valid

type Flags

type Flags []Flag

Flags type is a list of command line flags

func (*Flags) AppendHelpIfNotPresent

func (f *Flags) AppendHelpIfNotPresent()

AppendHelpIfNotPresent if the help flag is not present in the underlying slice append the default one

func (*Flags) AppendVersionIfNotPreset

func (f *Flags) AppendVersionIfNotPreset()

AppendVersionIfNotPreset if the version flag is not present in the underlying slice append the default one

func (Flags) Bool

func (f Flags) Bool(arg string) bool

Bool return the bool value of the arg

func (Flags) Flag

func (f Flags) Flag(name string) *Flag

Flag returns the flag that matches the name provided

func (Flags) Float

func (f Flags) Float(arg string) float64

Float return the Float value of the arg

func (Flags) Int

func (f Flags) Int(arg string) int

Int return the int value of the flag

func (Flags) Parse

func (f Flags) Parse(args []string) ([]string, error)

Parse parses the command line arguments and returns the one that has are not flags

func (Flags) RequiredAreParsed

func (f Flags) RequiredAreParsed() error

RequiredAreParsed checks if all the required flags has been parsed

func (Flags) String

func (f Flags) String(arg string) string

String return the string value of the arg

func (Flags) Validate

func (f Flags) Validate() error

Validate checks all flags to be validated

Jump to

Keyboard shortcuts

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