cli

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package cli provides functions to build the selector command line interface

Package cli provides functions to build the selector command line interface

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandLineInterface

type CommandLineInterface struct {
	Flags map[string]interface{}
	// contains filtered or unexported fields
}

CommandLineInterface is a type to group CLI funcs and state

func New

func New(binaryName string, shortUsage string, longUsage, examples string) CommandLineInterface

New creates an instance of CommandLineInterface

func (*CommandLineInterface) BoolFlag

func (cl *CommandLineInterface) BoolFlag(name string, shorthand *string, defaultValue *bool, description string)

BoolFlag creates and registers a flag accepting a boolean

func (*CommandLineInterface) BoolFlagOnFlagSet

func (cl *CommandLineInterface) BoolFlagOnFlagSet(flagSet *pflag.FlagSet, name string, shorthand *string, defaultValue *bool, description string)

BoolFlagOnFlagSet creates and registers a flag accepting a boolean for configuration purposes.

func (*CommandLineInterface) BoolMe

func (*CommandLineInterface) BoolMe(i interface{}) *bool

BoolMe takes an interface and returns a pointer to a bool value If the underlying interface kind is not bool or *bool then nil is returned

func (*CommandLineInterface) ConfigBoolFlag

func (cl *CommandLineInterface) ConfigBoolFlag(name string, shorthand *string, defaultValue *bool, description string)

ConfigBoolFlag creates and registers a flag accepting a boolean for configuration purposes. Config flags will be grouped at the bottom in the output of --help

func (*CommandLineInterface) ConfigIntFlag

func (cl *CommandLineInterface) ConfigIntFlag(name string, shorthand *string, defaultValue *int, description string)

ConfigIntFlag creates and registers a flag accepting an Integer for configuration purposes. Config flags will be grouped at the bottom in the output of --help

func (*CommandLineInterface) ConfigStringFlag

func (cl *CommandLineInterface) ConfigStringFlag(name string, shorthand *string, defaultValue *string, description string, validationFn validator)

ConfigStringFlag creates and registers a flag accepting a String for configuration purposes. Config flags will be grouped at the bottom in the output of --help

func (*CommandLineInterface) Float64Me

func (*CommandLineInterface) Float64Me(i interface{}) *float64

Float64Me takes an interface and returns a pointer to a float64 value If the underlying interface kind is not float64 or *float64 then nil is returned

func (*CommandLineInterface) IntFlag

func (cl *CommandLineInterface) IntFlag(name string, shorthand *string, defaultValue *int, description string)

IntFlag creates and registers a flag accepting an Integer

func (*CommandLineInterface) IntFlagOnFlagSet

func (cl *CommandLineInterface) IntFlagOnFlagSet(flagSet *pflag.FlagSet, name string, shorthand *string, defaultValue *int, description string)

IntFlagOnFlagSet creates and registers a flag accepting an Integer

func (*CommandLineInterface) IntMe

func (*CommandLineInterface) IntMe(i interface{}) *int

IntMe takes an interface and returns a pointer to an int value If the underlying interface kind is not int or *int then nil is returned

func (*CommandLineInterface) IntMinMaxRangeFlagOnFlagSet

func (cl *CommandLineInterface) IntMinMaxRangeFlagOnFlagSet(flagSet *pflag.FlagSet, name string, shorthand *string, defaultValue *int, description string)

IntMinMaxRangeFlagOnFlagSet creates and registers a min, max, and helper flag each accepting an Integer

func (*CommandLineInterface) IntMinMaxRangeFlags

func (cl *CommandLineInterface) IntMinMaxRangeFlags(name string, shorthand *string, defaultValue *int, description string)

IntMinMaxRangeFlags creates and registers a min, max, and helper flag each accepting an Integer

func (*CommandLineInterface) IntRangeMe

func (*CommandLineInterface) IntRangeMe(i interface{}) *selector.IntRangeFilter

IntRangeMe takes an interface and returns a pointer to an IntRangeFilter value If the underlying interface kind is not IntRangeFilter or *IntRangeFilter then nil is returned

func (*CommandLineInterface) ParseAndValidateFlags

func (cl *CommandLineInterface) ParseAndValidateFlags() (map[string]interface{}, error)

ParseAndValidateFlags will parse flags registered in this instance of CLI from os.Args and then perform validation

func (*CommandLineInterface) ProcessRangeFilterFlags

func (cl *CommandLineInterface) ProcessRangeFilterFlags() error

ProcessRangeFilterFlags sets min and max to the appropriate 0 or maxInt bounds based on the 3-tuple that a user specifies for base flag, min, and/or max

func (*CommandLineInterface) RatioFlag

func (cl *CommandLineInterface) RatioFlag(name string, shorthand *string, defaultValue *string, description string) error

RatioFlag creates and registers a flag accepting a Ratio

func (*CommandLineInterface) SetUntouchedFlagValuesToNil

func (cl *CommandLineInterface) SetUntouchedFlagValuesToNil() error

SetUntouchedFlagValuesToNil iterates through all flags and sets their value to nil if they were not specifically set by the user This allows for a specified value, a negative value (like false or empty string), or an unspecified (nil) entry.

func (*CommandLineInterface) StringFlag

func (cl *CommandLineInterface) StringFlag(name string, shorthand *string, defaultValue *string, description string, validationFn validator)

StringFlag creates and registers a flag accepting a String and a validator function. The validator function is provided so that more complex flags can be created from a string input.

func (*CommandLineInterface) StringFlagOnFlagSet

func (cl *CommandLineInterface) StringFlagOnFlagSet(flagSet *pflag.FlagSet, name string, shorthand *string, defaultValue *string, description string, validationFn validator)

StringFlagOnFlagSet creates and registers a flag accepting a String and a validator function. The validator function is provided so that more complex flags can be created from a string input.

func (*CommandLineInterface) StringMe

func (*CommandLineInterface) StringMe(i interface{}) *string

StringMe takes an interface and returns a pointer to a string value If the underlying interface kind is not string or *string then nil is returned

func (*CommandLineInterface) SuiteBoolFlag

func (cl *CommandLineInterface) SuiteBoolFlag(name string, shorthand *string, defaultValue *bool, description string)

SuiteBoolFlag creates and registers a flag accepting a boolean for configuration purposes. Suite flags will be grouped in the middle of the output --help

func (*CommandLineInterface) ValidateFlags

func (cl *CommandLineInterface) ValidateFlags() error

ValidateFlags iterates through any registered validators and executes them

Jump to

Keyboard shortcuts

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