0.0.0 • Published 9 years ago
pull-prompt v0.0.0
pull-prompt
A CLI prompter for pull-streams
A pull-stream that maps questions to answers by prompting the user. It relies on prompt-skeleton ecosystem.
pull(
values([
{ type: 'text',
message: 'what is the first animal you think of?',
default: 'unicorn' },
{ type: 'confirm',
message: 'is the animal awesome?',
default: true }
]),
prompt(),
collect((err, answers) => {
// ...
})
)See examples/ for use with state management modules (like pull-stream-model and redux).
Installation
# with npm
npm i -s pull-prompt
# with yarn
yarn add pull-promptUsage
prompt()
A through stream that maps questions to what the user inputs.
pull(
questions(),
prompt(),
collect((err, answers) => {
// ...
})
)Questions
Questions are objects which have a minimum of { type, message }. They may contain extra properties from the prompt type (e.g. default, suggest) or the user (e.g. name: 'license')
'text' question
{
type: 'text',
message: 'What is your name?',
default: 'John Doe' // optional
}'confirm' question
{
type: 'confirm',
message: 'Do you agree to the terms?',
default: false, // optional
}'autocomplete' question
{
type: 'autocomplete',
message: 'What country do you live in?',
suggest: function (input) {
// ...
}
}The suggest function returns Promise<Array>. See cli-autocomplete for more info
Maintained by Jamen Marz (See on Twitter and GitHub for questions & updates)
0.0.0
9 years ago