interpoler

package
v0.0.0-...-351111d Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyCommand          = errors.New("empty command")
	ErrInvalidCommand        = errors.New("command is invalid")
	ErrInvalidParameterName  = errors.New("parameter name is invalid")
	ErrInvalidParameterValue = errors.New("parameter value is invalid")
	ErrEmptyParamaterValue   = errors.New("parameter value is not set")
)

Functions

This section is empty.

Types

type CommandNode

type CommandNode struct {
	Name                string
	Description         string
	ExtendedDescription string
	Parameters          []Parameter
	Executor            ExecutorFunc
}

type CommandNodes

type CommandNodes []*CommandNode

type CompleterFunc

type CompleterFunc func(ctx context.Context, funcOptions ParametersWithValue) []string

type ExecutorFunc

type ExecutorFunc func(ctx context.Context, funcOptions ParametersWithValue, writer *internal.Writer) error

type InterpolateError

type InterpolateError struct {
	Error   error
	Details string
}

func (InterpolateError) DetailedError

func (e InterpolateError) DetailedError() error

func (*InterpolateError) WithDetails

func (e *InterpolateError) WithDetails(details string) *InterpolateError

type InterpolateResult

type InterpolateResult struct {
	Parents                   CommandNodes
	Target                    *CommandNode
	TargetParameter           *Parameter
	Parameters                ParametersWithValue
	Remaining                 *TokanizedCommand
	Error                     *InterpolateError
	MisplacedCursor           bool
	MissingRequiredParameters []string
}

func Interpolate

func Interpolate(ctx context.Context, command *TokanizedCommand, nodes CommandNodes) *InterpolateResult

func NewInterpolateResult

func NewInterpolateResult() *InterpolateResult

func (*InterpolateResult) WithError

func (*InterpolateResult) WithMisplacedCursor

func (r *InterpolateResult) WithMisplacedCursor() *InterpolateResult

func (*InterpolateResult) WithMissingRequiredParameters

func (r *InterpolateResult) WithMissingRequiredParameters(missingReqParams []string) *InterpolateResult

func (*InterpolateResult) WithParameters

func (r *InterpolateResult) WithParameters(parameters ParametersWithValue) *InterpolateResult

func (*InterpolateResult) WithRemaining

func (r *InterpolateResult) WithRemaining(command *TokanizedCommand) *InterpolateResult

func (*InterpolateResult) WithTarget

func (r *InterpolateResult) WithTarget(target *CommandNode) *InterpolateResult

func (*InterpolateResult) WithTargetParameter

func (r *InterpolateResult) WithTargetParameter(parameter *Parameter) *InterpolateResult

type Parameter

type Parameter struct {
	Name        string
	Description string
	Completer   CompleterFunc
	Optional    bool
	Default     string
	Filter      bool
}

type ParameterWithValue

type ParameterWithValue struct {
	Parameter
	Value        string
	DefaultValue bool
	InvalidValue bool
}

func (*ParameterWithValue) AsBool

func (p *ParameterWithValue) AsBool() (bool, error)

func (*ParameterWithValue) AsInt32

func (p *ParameterWithValue) AsInt32() (int32, error)

func (*ParameterWithValue) AsInt64

func (p *ParameterWithValue) AsInt64() (int64, error)

type ParametersWithValue

type ParametersWithValue map[string]*ParameterWithValue

func (*ParametersWithValue) Get

func (*ParametersWithValue) IsSet

func (p *ParametersWithValue) IsSet(name string) bool

type TokanizedCommand

type TokanizedCommand struct {
	Tokens           []Token
	HasTrailingSpace bool
	CursorPos        int
}

func NewTokanizedCommand

func NewTokanizedCommand(tokens []Token, hasTrailingSpace bool, cursorPos int) *TokanizedCommand

func (*TokanizedCommand) Cut

func (*TokanizedCommand) Len

func (c *TokanizedCommand) Len() int

type Token

type Token struct {
	Value string
	Pos   int
}

Jump to

Keyboard shortcuts

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