A package for creating smart CLI interactions with customizable questions and answers.
Go to file
2017-07-28 14:29:26 +02:00
dist update dependencies and allow empty question set 2017-07-28 14:27:09 +02:00
test update dependencies and allow empty question set 2017-07-28 14:27:09 +02:00
ts update dependencies and allow empty question set 2017-07-28 14:27:09 +02:00
.gitignore initial 2016-11-20 01:11:22 +01:00
.gitlab-ci.yml update ci 2017-07-28 14:29:22 +02:00
npmextra.json add npmextra.json 2016-12-10 22:46:59 +01:00
package.json 1.0.6 2017-07-28 14:29:26 +02:00
README.md update README 2016-12-10 17:30:04 +01:00
tslint.json initial 2016-11-20 01:11:22 +01:00
yarn.lock update dependencies and allow empty question set 2017-07-28 14:27:09 +02:00

smartinteract

interact with terminal users

Availabililty

npm git git docs

Status for master

build status coverage report Dependency Status bitHound Dependencies bitHound Code TypeScript node JavaScript Style Guide

Usage

We recommend the use of TypeScript for best in class intellesense

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 }
})

Environment

In some environments like CI there is no user input to be expected. smartinteract will always directyl create an answer from the default value

npm