Resin.io CLI form interpreter
npm install resin-cli-formresin-cli-form
--------------




Join our online chat at 
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:
``sh`
$ npm install --save resin-cli-form
Documentation
-------------
* form
* [.run(form, [options])](#module_form.run) ⇒ Promise.<Object>
.ask(question) ⇒ Promise.<\>
form Promise.<Object> - answers | Param | Type | Default | Description |
| --- | --- | --- | --- |
| form | Array.<Object> | | form description |
| [options] | Object | {} | options |
| [options.override] | Object | | overrides |
Example
`js
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)
`$3
Kind: static method of form
Summary: Run a single form question
Returns: Promise.<\*> - answer
Access: public
| Param | Type | Description |
| --- | --- | --- |
| question | Object | form question |
Example
`js`
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:
`coffee`
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:
`sh`
$ 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:
`sh``
$ gulp lint
License
-------
The project is licensed under the Apache 2.0 license.