Skip to content

jamen/pull-prompt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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-prompt

Usage

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)

About

A CLI prompter for pull-streams

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published