action

package
v0.0.0-...-6d65439 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyStack = errors.New("empty stack")

Functions

func GuessContentType

func GuessContentType(v []byte) string

func GuessFormatIsBinary

func GuessFormatIsBinary(v []byte) bool

Types

type Action

type Action struct {
	Doc          string
	Names        []string // command and aliases
	Type         ActionType
	InputFormat  Format
	OutputFormat Format
	// change it to a variadic opts ...
	Func func(any) (any, error)
}

func (*Action) Description

func (a *Action) Description() string

func (*Action) FilterValue

func (a *Action) FilterValue() string

func (*Action) Title

func (a *Action) Title() string

func (*Action) Transform

func (a *Action) Transform(in *Data) (*Data, error)

type ActionRegistry

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

func DefaultRegistry

func DefaultRegistry() *ActionRegistry

func NewRegistry

func NewRegistry() *ActionRegistry

func (*ActionRegistry) ActionsForData

func (r *ActionRegistry) ActionsForData(data *Data) (actions []*Action)

func (*ActionRegistry) ActionsForText

func (r *ActionRegistry) ActionsForText(search string) (actions []*Action)

ActionsForText returns a list of actions, prefix by search, all if search is empty ordered alphabetically

func (*ActionRegistry) RegisterAction

func (r *ActionRegistry) RegisterAction(a Action)

RegisterAction registers an action by its input , names

func (*ActionRegistry) RegisterActions

func (r *ActionRegistry) RegisterActions(actions ...Action)

RegisterActions registers multiple actions by their input format, names

type ActionType

type ActionType uint16
const (
	TransformAction ActionType = iota
	ParseAction
)

type Data

type Data struct {
	RawValue       []byte
	Value          any
	Format         Format
	StructuredData map[string]any
	Stack          []*Action
}

Data to hold the current state of the input and the stack of applied transformations

func NewDataText

func NewDataText(v []byte) *Data

func (*Data) StackString

func (d *Data) StackString() string

func (*Data) StoreGeomValue

func (d *Data) StoreGeomValue(g geom.Geometry, a *Action) *Data

func (*Data) StoreJSONValue

func (d *Data) StoreJSONValue(t time.Time, a *Action) *Data

func (*Data) StoreTextListValue

func (d *Data) StoreTextListValue(l []string, a *Action) *Data

func (*Data) StoreTextValue

func (d *Data) StoreTextValue(v []byte, a *Action) *Data

func (*Data) StoreTimeValue

func (d *Data) StoreTimeValue(t time.Time, a *Action) *Data

func (*Data) String

func (d *Data) String() string

func (*Data) Undo

func (d *Data) Undo(in []byte) (*Data, *Action, error)

Undo removed the last actions if any Reapply the stack with input

type Format

type Format struct {
	Name   string
	Prefix string
}

func GuessFormat

func GuessFormat(v []byte) Format

Jump to

Keyboard shortcuts

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