input

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InputArgumentRequired = 1
	InputArgumentOptional = 2
	InputArgumentIsArray  = 4
)
View Source
const (
	InputOptionBool      = 1
	InputOptionRequired  = 2
	InputOptionOptional  = 4
	InputOptionIsArray   = 8
	InputOptionNegatable = 16
)

Variables

This section is empty.

Functions

func InputTypeToArray

func InputTypeToArray(value InputType) []string

func InputTypeToString

func InputTypeToString(value InputType) string

func ParseStringToArgs added in v0.9.1

func ParseStringToArgs(cmd string) []string

Types

type ArgvInput

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

func NewArgvInput

func NewArgvInput(argv []string, definition *InputDefinition) (*ArgvInput, error)

func (*ArgvInput) FirstArgument

func (input *ArgvInput) FirstArgument() InputType

func (*ArgvInput) HasParameterOption

func (input *ArgvInput) HasParameterOption(value string, onlyParams bool) bool

func (*ArgvInput) ParameterOption

func (input *ArgvInput) ParameterOption(value string, defaultValue InputType, onlyParams bool) InputType

func (*ArgvInput) Parse

func (input *ArgvInput) Parse() error

func (*ArgvInput) ToString

func (input *ArgvInput) ToString() string

type Input

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

func NewInput

func NewInput(definition *InputDefinition) (*Input, error)

func (*Input) Arguments

func (input *Input) Arguments() map[string]InputType

func (*Input) ArrayArgument

func (input *Input) ArrayArgument(name string) ([]string, error)

func (*Input) ArrayOption

func (input *Input) ArrayOption(name string) ([]string, error)

func (*Input) Bind

func (input *Input) Bind(definition *InputDefinition)

func (*Input) BoolOption

func (input *Input) BoolOption(name string) (bool, error)

func (*Input) EscapeToken

func (input *Input) EscapeToken(token string) string

func (*Input) HasArgument

func (input *Input) HasArgument(name string) bool

func (*Input) HasOption

func (input *Input) HasOption(name string) bool

func (*Input) IsInteractive

func (input *Input) IsInteractive() bool

func (*Input) Options

func (input *Input) Options() map[string]InputType

func (*Input) Parse

func (input *Input) Parse() error

func (*Input) SetArgument

func (input *Input) SetArgument(name string, value InputType) error

func (*Input) SetDefinition

func (input *Input) SetDefinition(definition *InputDefinition) error

func (*Input) SetInteractive

func (input *Input) SetInteractive(interactive bool)

func (*Input) SetOption

func (input *Input) SetOption(name string, value InputType) error

func (*Input) SetStream

func (input *Input) SetStream(stream *os.File)

func (*Input) Stream

func (input *Input) Stream() *os.File

func (*Input) StringArgument

func (input *Input) StringArgument(name string) (string, error)

func (*Input) StringOption

func (input *Input) StringOption(name string) (string, error)

func (*Input) Validate

func (input *Input) Validate() error

type InputArgument

type InputArgument struct {
	Name         string
	Description  string
	Mode         InputArgumentMode
	DefaultValue InputType
	Validator    InputValidator
	// contains filtered or unexported fields
}

func NewInputArgument

func NewInputArgument(name string, mode InputArgumentMode, description string) *InputArgument

func (*InputArgument) Clone added in v0.4.2

func (a *InputArgument) Clone() *InputArgument

func (*InputArgument) IsArray

func (a *InputArgument) IsArray() bool

func (*InputArgument) IsRequired

func (a *InputArgument) IsRequired() bool

func (*InputArgument) SetDefaultValue

func (a *InputArgument) SetDefaultValue(value InputType) *InputArgument

func (*InputArgument) SetValidator added in v0.4.2

func (a *InputArgument) SetValidator(validator InputValidator) *InputArgument

func (*InputArgument) WasConstructed added in v0.4.2

func (a *InputArgument) WasConstructed() bool

type InputArgumentMode

type InputArgumentMode uint8

type InputAwareInterface

type InputAwareInterface interface {
	SetInput(input InputInterface)
}

type InputDefinition

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

func NewInputDefinition

func NewInputDefinition(arguments []*InputArgument, options []*InputOption) *InputDefinition

func (*InputDefinition) AddArgument

func (definition *InputDefinition) AddArgument(argument *InputArgument)

func (*InputDefinition) AddArguments

func (definition *InputDefinition) AddArguments(arguments []*InputArgument)

func (*InputDefinition) AddOption

func (definition *InputDefinition) AddOption(option *InputOption)

func (*InputDefinition) AddOptions

func (definition *InputDefinition) AddOptions(options []*InputOption)

func (*InputDefinition) Argument

func (definition *InputDefinition) Argument(name string) (*InputArgument, error)

func (*InputDefinition) ArgumentByIndex

func (definition *InputDefinition) ArgumentByIndex(index uint) (*InputArgument, error)

func (*InputDefinition) ArgumentCount

func (definition *InputDefinition) ArgumentCount() uint

func (*InputDefinition) ArgumentDefaults

func (definition *InputDefinition) ArgumentDefaults() map[string]InputType

func (*InputDefinition) ArgumentRequiredCount

func (definition *InputDefinition) ArgumentRequiredCount() uint

func (*InputDefinition) Arguments

func (definition *InputDefinition) Arguments() map[string]*InputArgument

func (*InputDefinition) ArgumentsArray

func (definition *InputDefinition) ArgumentsArray() []*InputArgument

func (*InputDefinition) HasArgument

func (definition *InputDefinition) HasArgument(name string) bool

func (*InputDefinition) HasNegation

func (definition *InputDefinition) HasNegation(name string) bool

func (*InputDefinition) HasOption

func (definition *InputDefinition) HasOption(name string) bool

func (*InputDefinition) HasShortcut

func (definition *InputDefinition) HasShortcut(name string) bool

func (*InputDefinition) NegationToName

func (definition *InputDefinition) NegationToName(negation string) string

func (*InputDefinition) Option

func (definition *InputDefinition) Option(name string) (*InputOption, error)

func (*InputDefinition) OptionDefaults

func (definition *InputDefinition) OptionDefaults() map[string]InputType

func (*InputDefinition) OptionForShortcut

func (definition *InputDefinition) OptionForShortcut(shortcut string) (*InputOption, error)

func (*InputDefinition) Options

func (definition *InputDefinition) Options() map[string]*InputOption

func (*InputDefinition) OptionsArray

func (definition *InputDefinition) OptionsArray() []*InputOption

func (*InputDefinition) SetArguments

func (definition *InputDefinition) SetArguments(arguments []*InputArgument)

func (*InputDefinition) SetDefinition

func (definition *InputDefinition) SetDefinition(arguments []*InputArgument, options []*InputOption)

func (*InputDefinition) SetOptions

func (definition *InputDefinition) SetOptions(options []*InputOption)

func (*InputDefinition) ShortcutToName

func (definition *InputDefinition) ShortcutToName(shortcut string) string

func (*InputDefinition) Synopsis

func (definition *InputDefinition) Synopsis(short bool) string

type InputInterface

type InputInterface interface {
	FirstArgument() InputType
	HasParameterOption(value string, onlyParams bool) bool
	ParameterOption(value string, defaultValue InputType, onlyParams bool) InputType
	Bind(definition *InputDefinition)
	Parse() error
	Validate() error
	Arguments() map[string]InputType
	StringArgument(name string) (string, error)
	ArrayArgument(name string) ([]string, error)
	SetArgument(name string, value InputType) error
	HasArgument(name string) bool
	Options() map[string]InputType
	StringOption(name string) (string, error)
	BoolOption(name string) (bool, error)
	ArrayOption(name string) ([]string, error)
	SetOption(name string, value InputType) error
	HasOption(name string) bool
	IsInteractive() bool
	SetInteractive(interactive bool)
	ToString() string
}

func Make added in v0.8.0

func Make(s ...string) InputInterface

type InputOption

type InputOption struct {
	Name         string
	Shortcut     string
	Description  string
	Mode         InputOptionMode
	DefaultValue InputType
	Validator    InputValidator
	// contains filtered or unexported fields
}

func NewInputOption

func NewInputOption(name string, shortcut string, mode InputOptionMode, description string) *InputOption

func (*InputOption) AcceptValue

func (o *InputOption) AcceptValue() bool

func (*InputOption) Clone added in v0.4.2

func (o *InputOption) Clone() *InputOption

func (*InputOption) Equals

func (o *InputOption) Equals(opt *InputOption) bool

func (*InputOption) IsArray

func (o *InputOption) IsArray() bool

func (*InputOption) IsNegatable

func (o *InputOption) IsNegatable() bool

func (*InputOption) IsValueOptional

func (o *InputOption) IsValueOptional() bool

func (*InputOption) IsValueRequired

func (o *InputOption) IsValueRequired() bool

func (*InputOption) SetDefaultValue

func (o *InputOption) SetDefaultValue(value InputType) *InputOption

func (*InputOption) SetValidator added in v0.4.2

func (o *InputOption) SetValidator(validator InputValidator) *InputOption

func (*InputOption) WasConstructed added in v0.4.2

func (o *InputOption) WasConstructed() bool

type InputOptionMode

type InputOptionMode uint8

type InputParser

type InputParser func(self interface{}) error

type InputType

type InputType interface{}

type InputValidator

type InputValidator func(value InputType) error

type ObjectInput

type ObjectInput struct {
	*Input
	// contains filtered or unexported fields
}

func NewObjectInput

func NewObjectInput(parameters map[string]InputType, definition *InputDefinition) (*ObjectInput, error)

func (*ObjectInput) FirstArgument

func (input *ObjectInput) FirstArgument() InputType

func (*ObjectInput) HasParameterOption

func (input *ObjectInput) HasParameterOption(value string, onlyParams bool) bool

func (*ObjectInput) ParameterOption

func (input *ObjectInput) ParameterOption(value string, defaultValue InputType, onlyParams bool) InputType

func (*ObjectInput) Parse

func (input *ObjectInput) Parse() error

func (*ObjectInput) ToString

func (input *ObjectInput) ToString() string

type StreamableInputInterface

type StreamableInputInterface interface {
	SetStream(stream *os.File)
	Stream() *os.File
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳