Documentation ¶
Index ¶
- type Cmd
- type Cmds
- type Key
- type Map
- func (m *Map) Choose() (bool, Key, Shortcut, error)
- func (m *Map) Count() int
- func (m *Map) Delete(key Key)
- func (m *Map) FromFile(file string) error
- func (m *Map) FromJSON(b []byte) error
- func (m *Map) Index(index int) (Key, Shortcut, error)
- func (m *Map) Load(key Key) (Shortcut, bool)
- func (m *Map) Menu(showQuit bool) string
- func (m *Map) Range(f func(Key, Shortcut) bool)
- func (m *Map) Store(key Key, cmd ...*Cmd)
- type Shortcut
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd struct {
// contains filtered or unexported fields
}
Cmd is a shortcut command consisting of a name and arguments.
func Command ¶
Command returns a new Cmd with the specified name and arguments. If the command fails to initialize, panic with the error. If n < 0, first arg with %s will be treated as a loop argument.
func (*Cmd) Env ¶ added in v1.0.1
Env sets the environment variables for the command. The environment variables are specified as a slice of strings, with each string being in the form of "key=value". If multiple values are specified for the same key, the last one takes precedence. If env is empty, the environment variables of the parent process are used.
func (Cmd) MarshalJSON ¶
MarshalJSON returns the JSON representation of a Cmd.
func (Cmd) RunContext ¶
RunContext runs the command with the given context and arguments.
func (*Cmd) UnmarshalJSON ¶
UnmarshalJSON unmarshals the JSON representation of a Cmd. If the command fails to initialize, return an error.
type Cmds ¶
type Cmds struct {
// contains filtered or unexported fields
}
Cmds is a list of commands.
func (Cmds) MarshalJSON ¶
MarshalJSON marshals the list of commands to JSON. If the list has only one command, it marshals that command directly. Otherwise, it marshals the list of commands.
func (Cmds) RunContext ¶
RunContext executes the list of commands with the given context and arguments.
func (*Cmds) UnmarshalJSON ¶
UnmarshalJSON unmarshals the JSON representation of a Cmds. If any command fails to initialize, return an error.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map is a shortcut map that associates Key with one or multiple Cmds.
func (*Map) FromFile ¶
FromFile reads the content of the JSON file and populates the Map with the key-value pairs.
func (*Map) FromJSON ¶
FromJSON unmarshals a JSON byte array and populates the Map with the key-value pairs.
func (*Map) Load ¶
Load retrieves a Shortcut with the given key. It returns the Shortcut and true if the key exists. If the key does not exist, it returns nil and false.