commands

package
v0.0.0-...-1a3b2b2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 35 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 []opt.Completion, 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) ([]models.UID, error)

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

func MsgInfoFromUids

func MsgInfoFromUids(store *lib.MessageStore, uids []models.UID, 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) []models.UID

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" desc:"Target directory."`
}

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) Description

func (ChangeDirectory) Description() string

func (ChangeDirectory) Execute

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

type ChangeTab

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

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) Description

func (ChangeTab) Description() string

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) Description

func (Choose) Description() string

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) Description

func (Close) Description() string

func (Close) Execute

func (Close) Execute([]string) error

type Command

type Command interface {
	Description() string
	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 Echo

type Echo struct {
	Template string `opt:"..." required:"false"`
}

func (Echo) Aliases

func (Echo) Aliases() []string

func (Echo) Context

func (Echo) Context() CommandContext

func (Echo) Description

func (Echo) Description() string

func (Echo) Execute

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

type Eml

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

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) Description

func (Eml) Description() string

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) Description

func (ExecCmd) Description() string

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" desc:"Help topic."`
}

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) Description

func (Help) Description() string

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" desc:"Stop executing commands on the first error."`
	Background  bool   `opt:"-b" desc:"Do NOT spawn the popover dialog."`
	Accounts    bool   `opt:"-a" desc:"Feed command with account names."`
	Directories bool   `opt:"-d" desc:"Feed command with folder names."`
	Command     string `opt:"-c" desc:"Override [general].default-menu-cmd."`
	Xargs       string `opt:"..." complete:"CompleteXargs" desc:"Command name."`
}
func (Menu) Aliases() []string
func (*Menu) CompleteXargs(arg string) []string
func (Menu) Context() CommandContext
func (Menu) Description() string
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) Description

func (MoveTab) Description() string

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" desc:"Create a temporary account."`
}

func (NewAccount) Aliases

func (NewAccount) Aliases() []string

func (NewAccount) Context

func (NewAccount) Context() CommandContext

func (NewAccount) Description

func (NewAccount) Description() string

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) Description

func (NextPrevTab) Description() string

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) Description

func (PinTab) Description() string

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) Description

func (PrintWorkDir) Description() string

func (PrintWorkDir) Execute

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

type Prompt

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

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) Description

func (Prompt) Description() string

func (Prompt) Execute

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

type Quit

type Quit struct {
	Force bool `opt:"-f" desc:"Force quit even if a task is pending."`
}

func (Quit) Aliases

func (Quit) Aliases() []string

func (Quit) Context

func (Quit) Context() CommandContext

func (Quit) Description

func (Quit) Description() string

func (Quit) Execute

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

type Redraw

type Redraw struct{}

func (Redraw) Aliases

func (Redraw) Aliases() []string

func (Redraw) Context

func (Redraw) Context() CommandContext

func (Redraw) Description

func (Redraw) Description() string

func (Redraw) Execute

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

type Reload

type Reload struct {
	Binds bool   `opt:"-B" desc:"Reload binds.conf."`
	Conf  bool   `opt:"-C" desc:"Reload aerc.conf."`
	Style string `opt:"-s" complete:"CompleteStyle" desc:"Reload the specified styleset."`
}

func (Reload) Aliases

func (Reload) Aliases() []string

func (*Reload) CompleteStyle

func (r *Reload) CompleteStyle(s string) []string

func (Reload) Context

func (Reload) Context() CommandContext

func (Reload) Description

func (Reload) Description() string

func (Reload) Execute

func (r Reload) 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) Description

func (SendKeys) Description() string

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) Description

func (Suspend) Description() string

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) Description

func (Term) Description() string

func (Term) Execute

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

type Zoxide

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

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) Description

func (Zoxide) Description() string

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