Documentation ¶
Overview ¶
Package commands contains all functionality that is triggered by the user, either through keyboard bindings or the command-line interface. New commands such as 'sort', 'add', etc. must be implemented here.
Index ¶
- Constants
- Variables
- func Contexts(a api.API) []string
- func ErrMsgDataType(actual list.DataType, expected ...list.DataType) error
- func Keys() []string
- func RowContext(dataType list.DataType) string
- func TestCommand(data *TestData)
- func TestVerb(t *testing.T, verb string, tests []Test)
- type Add
- type Auth
- type Bind
- type Columns
- type Command
- func New(verb string, a api.API) Command
- func NewAdd(api api.API) Command
- func NewAuth(api api.API) Command
- func NewBind(api api.API) Command
- func NewColumns(api api.API) Command
- func NewCursor(api api.API) Command
- func NewCut(api api.API) Command
- func NewDevice(api api.API) Command
- func NewInputMode(api api.API) Command
- func NewIsolate(api api.API) Command
- func NewLike(api api.API) Command
- func NewList(api api.API) Command
- func NewNext(api api.API) Command
- func NewPaste(api api.API) Command
- func NewPause(api api.API) Command
- func NewPlay(api api.API) Command
- func NewPrevious(api api.API) Command
- func NewPrint(api api.API) Command
- func NewQuit(api api.API) Command
- func NewRecommend(api api.API) Command
- func NewRedraw(api api.API) Command
- func NewRename(api api.API) Command
- func NewRepeat(api api.API) Command
- func NewSeek(api api.API) Command
- func NewSelect(api api.API) Command
- func NewSet(api api.API) Command
- func NewShow(api api.API) Command
- func NewShuffle(api api.API) Command
- func NewSort(api api.API) Command
- func NewStop(api api.API) Command
- func NewStyle(api api.API) Command
- func NewUnbind(api api.API) Command
- func NewViewport(api api.API) Command
- func NewVolume(api api.API) Command
- func NewWrite(api api.API) Command
- func NewYank(api api.API) Command
- type Cursor
- type Cut
- type Device
- type InputMode
- type Isolate
- type Like
- type List
- func (cmd *List) Duplicate() error
- func (cmd *List) Exec() error
- func (cmd *List) Goto(id string) error
- func (cmd *List) New() error
- func (cmd *List) Parse() error
- func (c *List) ParseContext() (string, error)
- func (c *List) ParseTags(possibleTags []string) ([]string, error)
- func (c *List) TabComplete() []string
- type Next
- type Paste
- type Pause
- type Play
- type Previous
- type Print
- type Quit
- type Recommend
- type Redraw
- type Rename
- type Repeat
- type Seek
- type Select
- type Set
- type Show
- type Shuffle
- type Sort
- type Stop
- type Style
- type Test
- type TestData
- type Unbind
- type Viewport
- type Volume
- type Write
- type Yank
Constants ¶
const ( ClipboardsContext = "clipboards" DevicesContext = "devices" GlobalContext = "global" LibraryContext = "library" PlaylistsContext = "playlists" TracklistContext = "tracklist" WindowsContext = "windows" )
const ( SeedTypeArtist = "artist" SeedTypeGenre = "genre" SeedTypeTrack = "track" )
const ( RepeatOff = "off" RepeatContext = "context" RepeatTrack = "track" )
Variables ¶
var Verbs = map[string]func(api.API) Command{ "add": NewAdd, "auth": NewAuth, "bind": NewBind, "columns": NewColumns, "copy": NewYank, "cursor": NewCursor, "cut": NewCut, "device": NewDevice, "inputmode": NewInputMode, "isolate": NewIsolate, "like": NewLike, "list": NewList, "next": NewNext, "paste": NewPaste, "pause": NewPause, "play": NewPlay, "previous": NewPrevious, "prev": NewPrevious, "print": NewPrint, "q": NewQuit, "quit": NewQuit, "recommend": NewRecommend, "redraw": NewRedraw, "rename": NewRename, "repeat": NewRepeat, "seek": NewSeek, "select": NewSelect, "se": NewSet, "set": NewSet, "show": NewShow, "shuffle": NewShuffle, "sort": NewSort, "stop": NewStop, "style": NewStyle, "unbind": NewUnbind, "viewport": NewViewport, "volume": NewVolume, "w": NewWrite, "write": NewWrite, "yank": NewYank, }
Verbs contain mappings from strings to Command constructors. Make sure to add commands here when implementing them.
Functions ¶
func Contexts ¶
Return an ordered list of which program contexts active right now. Local contexts take precedence over global contexts.
func Keys ¶
func Keys() []string
Keys returns a string slice with all verbs that can be invoked to run a command.
func RowContext ¶
func TestCommand ¶
func TestCommand(data *TestData)
TestCommand runs a single test a for Command implementation.
Types ¶
type Add ¶
type Add struct {
// contains filtered or unexported fields
}
Add plays songs in the MPD playlist.
func (*Add) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Add) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Add) TabComplete ¶
func (c *Add) TabComplete() []string
TabComplete implements Command.TabComplete.
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth runs OAuth2 authentication flow against Spotify.
func (*Auth) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Auth) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Auth) TabComplete ¶
func (c *Auth) TabComplete() []string
TabComplete implements Command.TabComplete.
type Bind ¶
type Bind struct {
// contains filtered or unexported fields
}
Bind maps a key sequence to the execution of a command.
func (*Bind) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Bind) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Bind) TabComplete ¶
func (c *Bind) TabComplete() []string
TabComplete implements Command.TabComplete.
type Columns ¶
type Columns struct {
// contains filtered or unexported fields
}
Columns sets which column headers should be visible for the current list.
func (*Columns) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Columns) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Columns) TabComplete ¶
func (c *Columns) TabComplete() []string
TabComplete implements Command.TabComplete.
type Command ¶
type Command interface { // Exec executes the AST generated by the command. Exec() error // SetScanner assigns a scanner to the command. // FIXME: move to constructor? SetScanner(*lexer.Scanner) // Parse and make an abstract syntax tree. This function MUST NOT have any side effects. Parse() error // TabComplete returns a set of tokens that could possibly be used as the next // command parameter. TabComplete() []string // Scanned returns a slice of tokens that have been scanned using Parse(). Scanned() []parser.Token }
Command must be implemented by all commands.
func NewInputMode ¶
func NewPrevious ¶
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
Cursor moves the cursor in a songlist widget. It can take human-readable parameters such as 'up' and 'down', and it also accepts relative positions if a number is given.
func (*Cursor) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Cursor) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Cursor) TabComplete ¶
func (c *Cursor) TabComplete() []string
TabComplete implements Command.TabComplete.
type Cut ¶
type Cut struct {
// contains filtered or unexported fields
}
Cut removes songs from songlists.
func (*Cut) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Cut) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Cut) TabComplete ¶
func (c *Cut) TabComplete() []string
TabComplete implements Command.TabComplete.
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device seeks forwards or backwards in the currently playing track.
func (*Device) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Device) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Device) TabComplete ¶
func (c *Device) TabComplete() []string
TabComplete implements Command.TabComplete.
type InputMode ¶
type InputMode struct {
// contains filtered or unexported fields
}
InputMode changes the Multibar's input mode.
func (*InputMode) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*InputMode) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*InputMode) TabComplete ¶
func (c *InputMode) TabComplete() []string
TabComplete implements Command.TabComplete.
type Isolate ¶
type Isolate struct {
// contains filtered or unexported fields
}
Isolate searches for songs that have similar tags as the selection.
func (*Isolate) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Isolate) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Isolate) TabComplete ¶
func (c *Isolate) TabComplete() []string
TabComplete implements Command.TabComplete.
type Like ¶
type Like struct {
// contains filtered or unexported fields
}
Like plays songs in the MPD playlist.
func (*Like) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Like) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Like) TabComplete ¶
func (c *Like) TabComplete() []string
TabComplete implements Command.TabComplete.
type List ¶
type List struct {
// contains filtered or unexported fields
}
List navigates and manipulates songlists.
func (*List) Goto ¶
Goto loads an external list and applies default columns and sorting. Local, cached versions are tried first.
func (*List) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*List) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*List) TabComplete ¶
func (c *List) TabComplete() []string
TabComplete implements Command.TabComplete.
type Next ¶
type Next struct {
// contains filtered or unexported fields
}
Next instructs the player to go to the next song.
func (*Next) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Next) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Next) TabComplete ¶
func (c *Next) TabComplete() []string
TabComplete implements Command.TabComplete.
type Paste ¶
type Paste struct {
// contains filtered or unexported fields
}
Paste inserts songs from the clipboard.
func (*Paste) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Paste) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Paste) TabComplete ¶
func (c *Paste) TabComplete() []string
TabComplete implements Command.TabComplete.
type Pause ¶
type Pause struct {
// contains filtered or unexported fields
}
Pause toggles play/paused state.
func (*Pause) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Pause) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Pause) TabComplete ¶
func (c *Pause) TabComplete() []string
TabComplete implements Command.TabComplete.
type Play ¶
type Play struct {
// contains filtered or unexported fields
}
Play plays songs in the MPD playlist.
func (*Play) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Play) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Play) TabComplete ¶
func (c *Play) TabComplete() []string
TabComplete implements Command.TabComplete.
type Previous ¶
type Previous struct {
// contains filtered or unexported fields
}
Previous instructs the player to go to the previous song.
func (*Previous) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Previous) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Previous) TabComplete ¶
func (c *Previous) TabComplete() []string
TabComplete implements Command.TabComplete.
type Print ¶
type Print struct {
// contains filtered or unexported fields
}
Print displays information about the selected song's tags.
func (*Print) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Print) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Print) TabComplete ¶
func (c *Print) TabComplete() []string
TabComplete implements Command.TabComplete.
type Quit ¶
type Quit struct {
// contains filtered or unexported fields
}
Quit exits the program.
func (*Quit) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Quit) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Quit) TabComplete ¶
func (c *Quit) TabComplete() []string
TabComplete implements Command.TabComplete.
type Recommend ¶
type Recommend struct {
// contains filtered or unexported fields
}
Recommend gives a list of tracks similar to the ones selected and within certain constraints. Effectively it implements "track radio" from the official client, but with granular control.
func (*Recommend) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Recommend) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Recommend) TabComplete ¶
func (c *Recommend) TabComplete() []string
TabComplete implements Command.TabComplete.
type Redraw ¶
type Redraw struct {
// contains filtered or unexported fields
}
Redraw forcefully redraws the screen.
func (*Redraw) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Redraw) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Redraw) TabComplete ¶
func (c *Redraw) TabComplete() []string
TabComplete implements Command.TabComplete.
type Rename ¶
type Rename struct {
// contains filtered or unexported fields
}
Rename saves a local tracklist to Spotify.
func (*Rename) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Rename) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Rename) TabComplete ¶
func (c *Rename) TabComplete() []string
TabComplete implements Command.TabComplete.
type Repeat ¶
type Repeat struct {
// contains filtered or unexported fields
}
Repeat sets the playback repeat mode.
func (*Repeat) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Repeat) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Repeat) TabComplete ¶
func (c *Repeat) TabComplete() []string
TabComplete implements Command.TabComplete.
type Seek ¶
type Seek struct {
// contains filtered or unexported fields
}
Seek seeks forwards or backwards in the currently playing track.
func (*Seek) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Seek) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Seek) TabComplete ¶
func (c *Seek) TabComplete() []string
TabComplete implements Command.TabComplete.
type Select ¶
type Select struct {
// contains filtered or unexported fields
}
Select manipulates song selection within a songlist.
func (*Select) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Select) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Select) TabComplete ¶
func (c *Select) TabComplete() []string
TabComplete implements Command.TabComplete.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set manipulates a Options table by parsing input tokens from the "set" command.
func (*Set) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Set) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Set) TabComplete ¶
func (c *Set) TabComplete() []string
TabComplete implements Command.TabComplete.
type Show ¶
type Show struct {
// contains filtered or unexported fields
}
Show directs which window (main widget) to show.
func (*Show) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Show) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Show) TabComplete ¶
func (c *Show) TabComplete() []string
TabComplete implements Command.TabComplete.
type Shuffle ¶
type Shuffle struct {
// contains filtered or unexported fields
}
Shuffle sets the playback shuffle mode.
func (*Shuffle) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Shuffle) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Shuffle) TabComplete ¶
func (c *Shuffle) TabComplete() []string
TabComplete implements Command.TabComplete.
type Sort ¶
type Sort struct {
// contains filtered or unexported fields
}
Sort sorts songlists.
func (*Sort) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Sort) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Sort) TabComplete ¶
func (c *Sort) TabComplete() []string
TabComplete implements Command.TabComplete.
type Stop ¶
type Stop struct {
// contains filtered or unexported fields
}
Stop stops song playback.
func (*Stop) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Stop) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Stop) TabComplete ¶
func (c *Stop) TabComplete() []string
TabComplete implements Command.TabComplete.
type Style ¶
type Style struct {
// contains filtered or unexported fields
}
Style manipulates the style table, allowing to set colors and attributes for UI elements.
func (*Style) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Style) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Style) TabComplete ¶
func (c *Style) TabComplete() []string
TabComplete implements Command.TabComplete.
type Test ¶
type Test struct { // The input data for the command, as seen on the command line. Input string // True if the command should parse and execute properly, false otherwise. Success bool // An initialization function for tests. Init func(data *TestData) // A callback function to call for every test, allowing customization of tests. Callback func(data *TestData) // A slice of tab completion candidates to expect. TabComplete []string }
Test is a structure for test data, and can be used to conveniently test Command instances.
type Unbind ¶
type Unbind struct {
// contains filtered or unexported fields
}
Unbind unmaps a key sequence.
func (*Unbind) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Unbind) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Unbind) TabComplete ¶
func (c *Unbind) TabComplete() []string
TabComplete implements Command.TabComplete.
type Viewport ¶
type Viewport struct {
// contains filtered or unexported fields
}
Viewport acts on the viewport, such as scrolling the current songlist.
func (*Viewport) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Viewport) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Viewport) TabComplete ¶
func (c *Viewport) TabComplete() []string
TabComplete implements Command.TabComplete.
type Volume ¶
type Volume struct {
// contains filtered or unexported fields
}
Volume adjusts MPD's volume.
func (*Volume) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Volume) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Volume) TabComplete ¶
func (c *Volume) TabComplete() []string
TabComplete implements Command.TabComplete.
type Write ¶
type Write struct {
// contains filtered or unexported fields
}
Write saves a local tracklist to Spotify.
func (*Write) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Write) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Write) TabComplete ¶
func (c *Write) TabComplete() []string
TabComplete implements Command.TabComplete.
type Yank ¶
type Yank struct {
// contains filtered or unexported fields
}
Yank copies tracks from the songlist into the clipboard.
func (*Yank) ParseContext ¶
ParseContext parses a single identifier and verifies that it is a program context.
func (*Yank) ParseTags ¶
ParseTags parses a set of tags until the end of the line, and maintains the tab complete list according to a specified song.
func (*Yank) TabComplete ¶
func (c *Yank) TabComplete() []string
TabComplete implements Command.TabComplete.
Source Files ¶
- add.go
- auth.go
- bind.go
- columns.go
- command.go
- cursor.go
- cut.go
- device.go
- error_messages.go
- inputmode.go
- isolate.go
- like.go
- list.go
- next.go
- paste.go
- pause.go
- play.go
- previous.go
- print.go
- quit.go
- recommend.go
- redraw.go
- rename.go
- repeat.go
- seek.go
- select.go
- set.go
- show.go
- shuffle.go
- sort.go
- stop.go
- style.go
- test.go
- unbind.go
- viewport.go
- volume.go
- write.go
- yank.go