commands

package
v0.0.0-...-0798a42 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NONE = 1 << iota
	// available everywhere
	GLOBAL
	// only when a message list is focused
	MESSAGE_LIST
	// only when a message viewer is focused
	MESSAGE_VIEWER
	// only when a message composer is focused
	COMPOSE
	// only when a terminal
	TERMINAL
)

Variables

View Source
var CmdHistory = cmdHistory{}

CmdHistory is the history of executed commands

Functions

func ActiveCommandNames

func ActiveCommandNames() []string

func CompletePath

func CompletePath(path string, onlyDirs bool) []string

CompletePath provides filesystem completions given a starting path.

func ExecuteCommand

func ExecuteCommand(cmd Command, cmdline string) error

func ExpandTemplates

func ExpandTemplates(
	s string, cfg *config.AccountConfig, msg *models.MessageInfo,
) (string, error)

expand template expressions

func FilterList

func FilterList(
	valid []string, search string, postProc func(string) string,
) []string

FilterList takes a list of valid completions and filters it, either by case smart prefix, or by fuzzy matching An optional post processing function can be passed to prepend, append or quote each value.

func GetAddress

func GetAddress(search string) []string

GetAddress uses the address-book-cmd for address completion

func GetCompletions

func GetCompletions(
	cmd Command, args *opt.Args,
) (options []string, prefix string)

GetCompletions returns the completion options and the command prefix

func GetDateList

func GetDateList() []string

GetDateList returns a list of date terms for completion

func GetFlagList

func GetFlagList() []string

GetFlagList returns a list of available flags for completion

func GetFolders

func GetFolders(arg string) []string

func GetLabels

func GetLabels(arg string) []string

func GetTemplateCompletion

func GetTemplateCompletion(
	cmd string,
) ([]string, string, bool)

func GetTemplates

func GetTemplates(arg string) []string

func MarkedOrSelected

func MarkedOrSelected(pm app.ProvidesMessages) ([]uint32, error)

MarkedOrSelected returns either all marked messages if any are marked or the selected message instead

func MsgInfoFromUids

func MsgInfoFromUids(store *lib.MessageStore, uids []uint32, statusInfo func(string)) ([]*models.MessageInfo, error)

func Operands

func Operands(args []string, spec string) []string

Operands returns a slice without any option flags or mandatory option arguments

func QuickTerm

func QuickTerm(args []string, stdin io.Reader, silent bool) (*app.Terminal, error)

QuickTerm is an ephemeral terminal for running a single command and quitting.

func QuoteSpace

func QuoteSpace(s string) string

func Register

func Register(cmd Command)

func TermCore

func TermCore(args []string) error

The help command is an alias for `term man` thus Term requires a simple func

func TermCoreDirectory

func TermCoreDirectory(args []string, dir string) error

func UidsFromMessageInfos

func UidsFromMessageInfos(msgs []*models.MessageInfo) []uint32

UidsFromMessageInfos extracts a uid slice from a slice of MessageInfos

func ZoxideAdd

func ZoxideAdd(arg string) error

func ZoxideQuery

func ZoxideQuery(args []string) (string, error)

Types

type ChangeDirectory

type ChangeDirectory struct {
	Target string `opt:"directory" default:"~" complete:"CompleteTarget"`
}

func (ChangeDirectory) Aliases

func (ChangeDirectory) Aliases() []string

func (*ChangeDirectory) CompleteTarget

func (*ChangeDirectory) CompleteTarget(arg string) []string

func (ChangeDirectory) Context

func (ChangeDirectory) Context() CommandContext

func (ChangeDirectory) Execute

func (cd ChangeDirectory) Execute(args []string) error

type ChangeTab

type ChangeTab struct {
	Tab string `opt:"tab" complete:"CompleteTab"`
}

func (ChangeTab) Aliases

func (ChangeTab) Aliases() []string

func (*ChangeTab) CompleteTab

func (*ChangeTab) CompleteTab(arg string) []string

func (ChangeTab) Context

func (ChangeTab) Context() CommandContext

func (ChangeTab) Execute

func (c ChangeTab) Execute(args []string) error

type Choose

type Choose struct {
	Unused struct{} `opt:"-"`
}

func (Choose) Aliases

func (Choose) Aliases() []string

func (Choose) Context

func (Choose) Context() CommandContext

func (Choose) Execute

func (Choose) Execute(args []string) error

type Close

type Close struct{}

func (Close) Aliases

func (Close) Aliases() []string

func (Close) Context

func (Close) Context() CommandContext

func (Close) Execute

func (Close) Execute([]string) error

type Command

type Command interface {
	Context() CommandContext
	Aliases() []string
	Execute([]string) error
}

func ActiveCommands

func ActiveCommands() []Command

func ExpandAbbreviations

func ExpandAbbreviations(name string) (string, Command, error)

Expand non-ambiguous command abbreviations.

q  --> quit
ar --> archive
im --> import-mbox

func ResolveCommand

func ResolveCommand(
	cmdline string, acct *config.AccountConfig, msg *models.MessageInfo,
) (string, Command, error)

type CommandContext

type CommandContext uint32

func CurrentContext

func CurrentContext() CommandContext

type Eml

type Eml struct {
	Path string `opt:"path" required:"false" complete:"CompletePath"`
}

func (Eml) Aliases

func (Eml) Aliases() []string

func (*Eml) CompletePath

func (*Eml) CompletePath(arg string) []string

func (Eml) Context

func (Eml) Context() CommandContext

func (Eml) Execute

func (e Eml) Execute(args []string) error

type ErrorExit

type ErrorExit int

func (ErrorExit) Error

func (err ErrorExit) Error() string

type ExecCmd

type ExecCmd struct {
	Args []string `opt:"..."`
}

func (ExecCmd) Aliases

func (ExecCmd) Aliases() []string

func (ExecCmd) Context

func (ExecCmd) Context() CommandContext

func (ExecCmd) Execute

func (e ExecCmd) Execute(args []string) error

type Help

type Help struct {
	Topic string `opt:"topic" action:"ParseTopic" default:"aerc" complete:"CompleteTopic"`
}

func (Help) Aliases

func (Help) Aliases() []string

func (*Help) CompleteTopic

func (*Help) CompleteTopic(arg string) []string

func (Help) Context

func (Help) Context() CommandContext

func (Help) Execute

func (h Help) Execute(args []string) error

func (*Help) ParseTopic

func (h *Help) ParseTopic(arg string) error
type Menu struct {
	ErrExit     bool   `opt:"-e"`
	Background  bool   `opt:"-b"`
	Accounts    bool   `opt:"-a"`
	Directories bool   `opt:"-d"`
	Command     string `opt:"-c"`
	Xargs       string `opt:"..." complete:"CompleteXargs"`
}
func (Menu) Aliases() []string
func (*Menu) CompleteXargs(arg string) []string
func (Menu) Context() CommandContext
func (m Menu) Execute([]string) error

type MoveTab

type MoveTab struct {
	Index    int `opt:"index" metavar:"[+|-]<index>" action:"ParseIndex"`
	Relative bool
}

func (MoveTab) Aliases

func (MoveTab) Aliases() []string

func (MoveTab) Context

func (MoveTab) Context() CommandContext

func (MoveTab) Execute

func (m MoveTab) Execute(args []string) error

func (*MoveTab) ParseIndex

func (m *MoveTab) ParseIndex(arg string) error

type NewAccount

type NewAccount struct {
	Temp bool `opt:"-t"`
}

func (NewAccount) Aliases

func (NewAccount) Aliases() []string

func (NewAccount) Context

func (NewAccount) Context() CommandContext

func (NewAccount) Execute

func (n NewAccount) Execute(args []string) error

type NextPrevTab

type NextPrevTab struct {
	Offset int `opt:"n" default:"1"`
}

func (NextPrevTab) Aliases

func (NextPrevTab) Aliases() []string

func (NextPrevTab) Context

func (NextPrevTab) Context() CommandContext

func (NextPrevTab) Execute

func (np NextPrevTab) Execute(args []string) error

type NoSuchCommand

type NoSuchCommand string

func (NoSuchCommand) Error

func (err NoSuchCommand) Error() string

type PinTab

type PinTab struct{}

func (PinTab) Aliases

func (PinTab) Aliases() []string

func (PinTab) Context

func (PinTab) Context() CommandContext

func (PinTab) Execute

func (PinTab) Execute(args []string) error

type PrintWorkDir

type PrintWorkDir struct{}

func (PrintWorkDir) Aliases

func (PrintWorkDir) Aliases() []string

func (PrintWorkDir) Context

func (PrintWorkDir) Context() CommandContext

func (PrintWorkDir) Execute

func (PrintWorkDir) Execute(args []string) error

type Prompt

type Prompt struct {
	Text string   `opt:"text"`
	Cmd  []string `opt:"..." complete:"CompleteCommand"`
}

func (Prompt) Aliases

func (Prompt) Aliases() []string

func (*Prompt) CompleteCommand

func (*Prompt) CompleteCommand(arg string) []string

func (Prompt) Context

func (Prompt) Context() CommandContext

func (Prompt) Execute

func (p Prompt) Execute(args []string) error

type Quit

type Quit struct {
	Force bool `opt:"-f"`
}

func (Quit) Aliases

func (Quit) Aliases() []string

func (Quit) Context

func (Quit) Context() CommandContext

func (Quit) Execute

func (q Quit) Execute(args []string) error

type SendKeys

type SendKeys struct {
	Keys string `opt:"..."`
}

func (SendKeys) Aliases

func (SendKeys) Aliases() []string

func (SendKeys) Context

func (SendKeys) Context() CommandContext

func (SendKeys) Execute

func (s SendKeys) Execute(args []string) error

type Suspend

type Suspend struct{}

func (Suspend) Aliases

func (Suspend) Aliases() []string

func (Suspend) Context

func (Suspend) Context() CommandContext

func (Suspend) Execute

func (Suspend) Execute(args []string) error

type Term

type Term struct {
	Cmd []string `opt:"..." required:"false"`
}

func (Term) Aliases

func (Term) Aliases() []string

func (Term) Context

func (Term) Context() CommandContext

func (Term) Execute

func (t Term) Execute(args []string) error

type Zoxide

type Zoxide struct {
	Args []string `opt:"..." required:"false" metavar:"<query>..." complete:"CompleteFolder"`
}

func (Zoxide) Aliases

func (Zoxide) Aliases() []string

func (*Zoxide) CompleteFolder

func (*Zoxide) CompleteFolder(arg string) []string

func (Zoxide) Context

func (Zoxide) Context() CommandContext

func (Zoxide) Execute

func (z Zoxide) Execute(args []string) error

Execute calls zoxide add and query and delegates actually changing the directory to ChangeDirectory

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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