command

package
v0.4.28 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotImplemented        = errors.New("not yet implemented")
	ErrNoKeywords            = errors.New("no keywords")
	ErrEmptyKeyword          = errors.New("empty keyword")
	ErrDuplicateKeyword      = errors.New("duplicate keyword definition")
	ErrUnknownCommand        = errors.New("unknown command")
	ErrUnexpectedCommand     = errors.New("unexpected command")
	ErrUnexpectedPreposition = errors.New("unexpected preposition")
	ErrUnexpectedArgument    = errors.New("unexpected argument")
	ErrDanglingPreposition   = errors.New("dangling preposition")
	ErrMissingArguments      = errors.New("missing arguments")
	ErrUnknownProfile        = errors.New("unknown profile")
	ErrMissingProfileName    = errors.New("missing profile name")
)

Functions

func NewLexer added in v0.4.20

func NewLexer(opts ...lexOption) *lexer

func ParseColumnFlags added in v0.4.20

func ParseColumnFlags(argFlags string) (flags, mask column.Flags)

ParseColumnFlags parses the flags provided after a column name with a "~" suffix

The flags provided after a "~" suffix should be any combination of at most one each of the alignment, sorting direction and sorting priority flags.

Not all combinations makes sense! (e.g. "name~:--:^v12")

| flag |                    description                     |
| ---- | -------------------------------------------------- |
|      | reset all column flags (flags marker but no flags) |
| -    | reset column alignment                             |
| ~    | reset sorting flags                                |
| ---- | -------------------------------------------------- |
| :    | align left                                         |
| :-   | align left                                         |
| -:   | align right                                        |
| ::   | align center                                       |
| -:-  | align center (alternative)                         |
| .    | align on decimal point                             |
| ..   | align by version                                   |
| ---- | -------------------------------------------------- |
| ^    | sort in ascending order                            |
| v    | sort in descending order                           |
| 0-7  | sorting priority                                   |

Types

type BuilderBase

type BuilderBase struct {
	Keywords     *keyword.Set
	ProfileNames []string
}

func (*BuilderBase) AddPreposition

func (b *BuilderBase) AddPreposition(string)

func (*BuilderBase) ColumnSpecifierFromArg added in v0.4.20

func (b *BuilderBase) ColumnSpecifierFromArg(arg string) *column.Specifier

ColumnSpecifierFromArg interprets an argument as a column name or position.

Purpose:

  • allow users to specify column names, positions and/or configuration with as little friction as possible
  • the normal use case is to simply use bare words which are interpreted as either a column name or position
  • a '.' prefix followed by a number => identify column by position only
  • a ':' prefix followed by a string => identify column by name only
  • a '~' suffix introduces alignment or sorting flags

func (*BuilderBase) IsKeyword added in v0.4.20

func (b *BuilderBase) IsKeyword(name string, id keyword.ID) bool

func (*BuilderBase) KeywordName added in v0.4.20

func (b *BuilderBase) KeywordName(id keyword.ID) string

type Parser

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

func NewParser added in v0.4.20

func NewParser(opts ...ParserOption) (*Parser, error)

func (*Parser) Parse

func (p *Parser) Parse(commandArgs []string) ([]api.Command, error)

func (*Parser) ParseToken added in v0.4.20

func (p *Parser) ParseToken(tok token)

type ParserOption added in v0.4.20

type ParserOption func(*Parser)

func WithKeywords added in v0.4.20

func WithKeywords(ks *keyword.Set) ParserOption

func WithProfileNames added in v0.4.20

func WithProfileNames(names []string) ParserOption

type TokenID added in v0.4.20

type TokenID int
const (
	ErrorTokenID       TokenID = iota // error token
	MatchPrefixTokenID                // "match" command keyword
	PrefixTokenID                     // "prefix" command keyword
	ProfileTokenID                    // "profile" command keyword
	LocaleTokenID                     // "locale" command keyword
	ConfigTokenID                     // "config" command keyword
	SortTokenID                       // "sort" command keyword
	DeleteTokenID                     // "delete" command keyword
	ClearTokenID                      // "clear" command keyword
	FillTokenID                       // "fill" command keyword
	PlaceTokenID                      // "place" command keyword
	MoveTokenID                       // "move" command keyword
	InsertTokenID                     // "insert" command keyword
	AppendTokenID                     // "append" command keyword
	BeforeTokenID                     // "before" preposition keyword
	AfterTokenID                      // "after" preposition keyword
	WithTokenID                       // "with" preposition keyword
	FirstTokenID                      // "first" column label keyword
	LastTokenID                       // "last" column label keyword
	ArgumentTokenID                   // any other string (valid argument)
)

func (TokenID) String added in v0.4.20

func (id TokenID) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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