input

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: Unlicense Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArgumentsMapKeys

func ArgumentsMapKeys(inputs map[string]argument.InputArgument) []string

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) Argument

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

Returns the argument value for a given argument name

func (*ArgvInput) ArgumentArrays

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

get all parsed arguments array

func (*ArgvInput) ArgumentList

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

Returns the argument array value for a given argument name

func (*ArgvInput) Arguments

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

get all parsed arguments

func (*ArgvInput) Bind

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

Binds the current input instance with the given arguments and options

func (*ArgvInput) Definition

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

get the input definition

func (*ArgvInput) FirstArgument

func (i *ArgvInput) FirstArgument() string

Returns the first argument from the raw parameters (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) Option

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

Returns the option value for a given option name

func (*ArgvInput) OptionList

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

Returns the option array value for a given option name

func (*ArgvInput) OptionLists

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

Returns all the given options array merged with the default values

func (*ArgvInput) Options

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

Returns all the given options merged with the default values

func (*ArgvInput) ParameterOption

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

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

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) SetArgumentList

func (i *ArgvInput) SetArgumentList(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) SetOptionList

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

Sets an option array value by name

func (*ArgvInput) Validate

func (i *ArgvInput) Validate()

Validates the input

func (*ArgvInput) ValidateArgv added in v1.3.2

func (i *ArgvInput) ValidateArgv()

type InputInterface

type InputInterface interface {
	// Returns the first argument from the raw parameters (not parsed).
	FirstArgument() 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.
	ParameterOption(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.
	Arguments() map[string]string

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

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

	// Returns the argument array value for a given array argument name.
	ArgumentList(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.
	SetArgumentList(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.
	Options() map[string]string

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

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

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

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

	// Sets an array option value by name.
	SetOptionList(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
	Definition() *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