resin-cli-form
Resin.io CLI form interpreter.
Role
The intention of this module is to provide an interpreter for our internal declarative form definitions.
Installation
Install resin-cli-form
by running:
$ npm install --save resin-cli-form
Documentation
- form
- .run(form, [options]) ⇒
Promise.<Object>
- .ask(question) ⇒
Promise.<*>
- .run(form, [options]) ⇒
Promise.<Object>
form.run(form, [options]) ⇒ Kind: static method of form
Summary: Run a form description
Returns: Promise.<Object>
- answers
Access: public
Param | Type | Default | Description |
---|---|---|---|
form | Array.<Object> |
form description | |
[options] | Object |
{} |
options |
[options.override] | Object |
overrides |
Example
formrun message: 'Processor' name: 'processorType' type: 'list' choices: 'Z7010' 'Z7020' message: 'Coprocessor cores' name: 'coprocessorCore' type: 'list' choices: '16' '64' # coprocessorCore will always be 64 # Notice that the question will not be asked at all override: coprocessorCore: '64' -> console
Promise.<*>
form.ask(question) ⇒ Kind: static method of form
Summary: Run a single form question
Returns: Promise.<*>
- answer
Access: public
Param | Type | Description |
---|---|---|
question | Object |
form question |
Example
formask message: 'Processor' type: 'list' choices: 'Z7010' 'Z7020' -> console
When
We use a when
property to determine the conditions needed for a question to be asked. This property consists of an object determining the value name (as key), and the value it must have (as value) for the condition to hold. A when
property can depend on one or more answers, by having many key value pairs.
Example:
formrun message: 'Network Type' name: 'network' type: 'list' choices: 'ethernet''wifi' message: 'Wifi Ssid' name: 'wifiSsid' type: 'input' when: network: 'wifi' message: 'Wifi Key' name: 'wifiKey' type: 'input' when: network: 'wifi'
In this case, the wifi ssid and wiki key will only be asked if the network type is wifi
.
Support
If you're having any problem, please raise an issue on GitHub and the Resin.io team will be happy to help.
Tests
Run the test suite by doing:
$ gulp test
Contribute
- Issue Tracker: github.com/resin-io-modules/resin-cli-form/issues
- Source Code: github.com/resin-io-modules/resin-cli-form
Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning:
$ gulp lint
License
The project is licensed under the Apache 2.0 license.