pull-prompt

0.0.0 • Public • Published

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)

Package Sidebar

Install

npm i pull-prompt

Weekly Downloads

1

Version

0.0.0

License

MIT

Last publish

Collaborators

  • npm