Back to Gluegun

Toolbox Parameters

docs/toolbox-parameters.md

5.2.22.3 KB
Original Source

Information about how the command was invoked. You can access this on the Gluegun toolbox. Check out this example of creating a new Reactotron plugin.

sh
gluegun reactotron plugin MyAwesomePlugin full --comments --lint standard
nametypepurposefrom the example above
pluginstringthe plugin used'reactotron'
commandstringthe command used'plugin'
stringstringthe command arguments as a string'MyAwesomePlugin full'
arrayarraythe command arguments as an array['MyAwesomePlugin', 'full']
firststringthe 1st argument'MyAwesomePlugin'
secondstringthe 2nd argument'full'
thirdstringthe 3rd argumentundefined
optionsobjectcommand line options{comments: true, lint: 'standard'}
argvobjectraw argv

options

Options are the command line flags. Always exists however it may be empty.

sh
gluegun say hello --loud -v --wave furiously
js
module.exports = async function(toolbox) {
  toolbox.parameters.options // { loud: true, v: true, wave: 'furiously' }
}

string

Everything else after the command as a string.

sh
gluegun say hello there
js
module.exports = async function(toolbox) {
  toolbox.parameters.string // 'hello there'
}

array

Everything else after the command, but as an array.

sh
gluegun reactotron plugin full
js
module.exports = async function(toolbox) {
  toolbox.parameters.array // ['plugin', 'full']
}

first / .second / .third

The first, second, and third element in array. It is provided as a shortcut, and there isn't one, this will be undefined.

sh
gluegun reactotron plugin full
js
module.exports = async function(toolbox) {
  toolbox.parameters.first // 'plugin'
  toolbox.parameters.second // 'full'
  toolbox.parameters.third // undefined
}