input

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgvInput

type ArgvInput struct {
	// contains filtered or unexported fields
}

ArgvInput represents an input coming from the CLI arguments

func NewArgvInput

func NewArgvInput(argv []string) *ArgvInput

constructor

func (*ArgvInput) Bind

func (i *ArgvInput) Bind(def definition.InputDefinition)

Binds the current Input instance with the given arguments and options

func (*ArgvInput) GetArgument

func (i *ArgvInput) GetArgument(name string) string

Returns the argument value for a given argument name

func (*ArgvInput) GetArgumentArray

func (i *ArgvInput) GetArgumentArray(name string) []string

Returns the argument array value for a given argument name

func (*ArgvInput) GetArgumentArrays

func (i *ArgvInput) GetArgumentArrays() map[string][]string

get all parsed arguments array

func (*ArgvInput) GetArguments

func (i *ArgvInput) GetArguments() map[string]string

get all parsed arguments

func (*ArgvInput) GetDefinition

func (i *ArgvInput) GetDefinition() *definition.InputDefinition

get the input definition

func (*ArgvInput) GetFirstArgument

func (i *ArgvInput) GetFirstArgument() string

Returns the first argument from the raw parameters (not parsed)

func (*ArgvInput) GetOption

func (i *ArgvInput) GetOption(name string) string

Returns the option value for a given option name

func (*ArgvInput) GetOptionArray

func (i *ArgvInput) GetOptionArray(name string) []string

Returns the option array value for a given option name

func (*ArgvInput) GetOptionArrays

func (i *ArgvInput) GetOptionArrays() map[string][]string

Returns all the given options array merged with the default values

func (*ArgvInput) GetOptions

func (i *ArgvInput) GetOptions() map[string]string

Returns all the given options merged with the default values

func (*ArgvInput) GetParameterOption

func (i *ArgvInput) GetParameterOption(values []string, defaultValue string, onlyParams bool)

Returns the value of a raw option (not parsed).

func (*ArgvInput) HasArgument

func (i *ArgvInput) HasArgument(name string) bool

Returns true if an InputArgument object exists by name or position

func (*ArgvInput) HasOption

func (i *ArgvInput) HasOption(name string) bool

Returns true if an InputOption object exists by name

func (*ArgvInput) HasParameterOption

func (i *ArgvInput) HasParameterOption(values []string, onlyParams bool) bool

Returns true if the raw parameters (not parsed) contain a value

func (*ArgvInput) IsInteractive

func (i *ArgvInput) IsInteractive() bool

Is this input means interactive?

func (*ArgvInput) Parse

func (i *ArgvInput) Parse()

Processes command line arguments

func (*ArgvInput) ParseArgv

func (i *ArgvInput) ParseArgv()

parse cli argv

func (*ArgvInput) SetArgument

func (i *ArgvInput) SetArgument(name string, value string)

Sets an argument value by name

func (*ArgvInput) SetArgumentArray

func (i *ArgvInput) SetArgumentArray(name string, value []string)

Sets an argument array value by name

func (*ArgvInput) SetInteractive

func (i *ArgvInput) SetInteractive(interactive bool)

Sets the input interactivity

func (*ArgvInput) SetOption

func (i *ArgvInput) SetOption(name string, value string)

Sets an option value by name

func (*ArgvInput) SetOptionArray

func (i *ArgvInput) SetOptionArray(name string, value []string)

Sets an option array value by name

func (*ArgvInput) Validate

func (i *ArgvInput) Validate()

Validates the input

type InputInterface

type InputInterface interface {
	// Returns the first argument from the raw parameters (not parsed).
	GetFirstArgument() string

	// Returns true if the raw parameters (not parsed) contain a value.
	//
	// This method is to be used to introspect the input parameters
	// before they have been validated. It must be used carefully.
	// Does not necessarily return the correct result for short options
	// when multiple flags are combined in the same option.
	HasParameterOption(values []string, onlyParams bool) bool

	// Returns the value of a raw option (not parsed).
	//
	// This method is to be used to introspect the input parameters
	// before they have been validated. It must be used carefully.
	// Does not necessarily return the correct result for short options
	// when multiple flags are combined in the same option.
	GetParameterOption(values []string, defaultValue string, onlyParams bool)

	// Binds the current Input instance with the given arguments and options.
	Bind(definition definition.InputDefinition)

	// Validates the input.
	Validate()

	// Parse the input data
	Parse()

	// Returns all the given arguments merged with the default values.
	GetArguments() map[string]string

	// Returns all the given array arguments merged with the default values.
	GetArgumentArrays() map[string][]string

	// Returns the argument value for a given argument name.
	GetArgument(name string) string

	// Returns the argument array value for a given array argument name.
	GetArgumentArray(name string) []string

	// Set the argument value for a given argument name.
	SetArgument(name string, value string)

	// Set the argument value for a given array argument name.
	SetArgumentArray(name string, value []string)

	// Returns the argument value for a given argument name.
	HasArgument(name string) bool

	// Returns all the given options merged with the default values.
	GetOptions() map[string]string

	// Returns all the given array options merged with the default values.
	GetOptionArrays() map[string][]string

	// Returns the option value for a given option name.
	GetOption(name string) string

	// Returns the option array value for a given array option name.
	GetOptionArray(name string) []string

	// Sets an option value by name.
	SetOption(name string, value string)

	// Sets an array option value by name.
	SetOptionArray(name string, value []string)

	// Returns true if an InputOption object exists by name.
	HasOption(name string) bool

	// Is this input means interactive?
	IsInteractive() bool

	// Sets the input interactivity.
	SetInteractive(bool)

	// Get the input definition
	GetDefinition() *definition.InputDefinition
}

InputInterface is the interface implemented by all input classes.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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