resin-cli-form v3.0.0
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-formDocumentation
- form
- .run(form, [options]) ⇒ Promise.<Object>
- .ask(question) ⇒ Promise.<*>
form.run(form, options) ⇒ Promise.<Object>
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
form.run [
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'
.then (answers) ->
console.log(answers)form.ask(question) ⇒ Promise.<*>
Kind: static method of form
Summary: Run a single form question
Returns: Promise.<*> - answer
Access: public
| Param | Type | Description |
|---|---|---|
| question | Object | form question |
Example
form.ask
message: 'Processor'
type: 'list'
choices: [ 'Z7010', 'Z7020' ]
.then (processor) ->
console.log(processor)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:
form.run [
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 testContribute
- 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 lintLicense
The project is licensed under the Apache 2.0 license.

