2017-07-28 14:45:41 +02:00
|
|
|
# smartinteract
|
2018-07-25 16:58:18 +02:00
|
|
|
|
2017-07-28 14:45:41 +02:00
|
|
|
smart cli interaction
|
|
|
|
|
|
|
|
## Availabililty
|
2018-07-25 16:58:18 +02:00
|
|
|
|
2017-07-28 14:45:41 +02:00
|
|
|
[](https://www.npmjs.com/package/smartinteract)
|
|
|
|
[](https://GitLab.com/pushrocks/smartinteract)
|
|
|
|
[](https://github.com/pushrocks/smartinteract)
|
|
|
|
[](https://pushrocks.gitlab.io/smartinteract/)
|
|
|
|
|
|
|
|
## Status for master
|
2018-07-25 16:58:18 +02:00
|
|
|
|
2017-07-28 14:45:41 +02:00
|
|
|
[](https://GitLab.com/pushrocks/smartinteract/commits/master)
|
|
|
|
[](https://GitLab.com/pushrocks/smartinteract/commits/master)
|
|
|
|
[](https://www.npmjs.com/package/smartinteract)
|
|
|
|
[](https://david-dm.org/pushrocks/smartinteract)
|
|
|
|
[](https://www.bithound.io/github/pushrocks/smartinteract/master/dependencies/npm)
|
|
|
|
[](https://www.bithound.io/github/pushrocks/smartinteract)
|
|
|
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
|
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
|
|
[](http://standardjs.com/)
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2018-07-25 16:58:18 +02:00
|
|
|
Use TypeScript for best in class instellisense.
|
2017-07-28 14:45:41 +02:00
|
|
|
|
|
|
|
```javascript
|
|
|
|
import { SmartInteract } from 'smartinteract'
|
|
|
|
|
|
|
|
let myInteract = new SmartInteract([{ // note: its an array. You can specify multiple questions
|
|
|
|
name: 'question1',
|
|
|
|
type: 'input',
|
|
|
|
message: 'Who are you?',
|
|
|
|
default: 'Somebody',
|
|
|
|
validate: (inputString) => { return true } // implement your own validation
|
|
|
|
}])
|
|
|
|
myInteract.addQuestions([ ... ]) // add more questions
|
|
|
|
myInteract.runQueue()
|
|
|
|
.then(answerBucket => { // the bucket has all the answers of the completed queue
|
|
|
|
let answerQuestion1 = answerBucket.getAnswerFor('question1')
|
|
|
|
// do something with the answers
|
|
|
|
})
|
|
|
|
|
|
|
|
// alternatively use .askQuestion() for more direct control
|
|
|
|
myInteract.askQuestion{ // note: its an array. You can specify multiple questions
|
|
|
|
name: 'question2',
|
|
|
|
type: 'confirm',
|
|
|
|
message: 'Do you speak English?',
|
|
|
|
default: true,
|
|
|
|
validate: (inputString) => { return true } // implement your own validation
|
|
|
|
}().then(answerObject => {
|
|
|
|
// answerObject looks like { name: 'question2', value: true }
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
For further information read the linked docs at the top of this README.
|
|
|
|
|
|
|
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
2018-07-25 16:58:18 +02:00
|
|
|
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
2017-07-28 14:45:41 +02:00
|
|
|
|
|
|
|
[](https://push.rocks)
|