A package for creating smart CLI interactions with customizable questions and answers.
Go to file
2016-12-10 17:30:04 +01:00
dist implement AnswerBucket 2016-11-20 22:24:09 +01:00
test implement AnswerBucket 2016-11-20 22:24:09 +01:00
ts implement AnswerBucket 2016-11-20 22:24:09 +01:00
.gitignore initial 2016-11-20 01:11:22 +01:00
.gitlab-ci.yml initial 2016-11-20 01:11:22 +01:00
package.json 1.0.2 2016-11-20 22:34:39 +01:00
README.md update README 2016-12-10 17:30:04 +01:00
tslint.json initial 2016-11-20 01:11:22 +01: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