docs » Commander

This spoon lets execute commands from other spoon by a chooser.

The way of Commander to generate it command list is it goes to each spoon and extract all public functions inside the spoon table. for each function the name is set to "spoonName.functionName". if the spoon has a table called commandderCommandTable, Commander will ignore everything else and take whatever is in the table. In this case the naming convention is the same. Then Commander grabs all the functions in global table. functions are tested against Commander.ignoredCommandList, except when spoon author provides a commanderCommandList.

Commander.chooser is the chooser, you can set background color, rows, etc, to it.

API Overview

API Documentation

Variables

commandTable
Signature Commander.commandTable
Type Variable
Description

This is the table which stores all the commands Each key is the name of the command, and each value is the actual function. you can add your custom commands to it.

forceLayout
Signature Commander.forceLayout
Type Variable
Description

If you want to switch to a layout when enabled chooser, set this to name of that layout

forceMethod
Signature Commander.forceMethod
Type Variable
Description

If you want to switch to a method when enabled chooser, set this to name of that method

ignoredCommandList
Signature Commander.ignoredCommandList
Type Variable
Description

This list contains all the ignored function names, any function matches the name inside this list will not be added to Commander.commandTable.

The list contains normal lua builtin functions and some hammerspoon functions that generally shouldn't be a command, such as init, bindHotkeys, etc.

Functions

addCommand
Signature Commander.addCommand(commandTable)
Type Function
Description

Add a command to Commander.commandTable

Parameters:

  • comamndTable - It is a table with same form of Commander.commandTable
               key is name of command, value is the function.

Note: Commander doesn't test the name against Commander.ignoredCommandList because it assumes you know what you are doing.

resetCommandTable
Signature Commander.resetCommandTable()
Type Function
Description

This function simply set Commander.commandTable to {}, Then the next time commander chooser is called it will generate the table again.

show
Signature Commander.show()
Type Function
Description

This function shows the command chooser. Bind this to a hotkey to use commander.