1.0.1 • Published 7 years ago

prompt-history v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

prompt-history NPM version NPM monthly downloads NPM total downloads

Tab through previous answer history.

Persist answers

prompt-history tabbing example

Tab through answer history

prompt-history tabbing example

Install

Install with npm:

$ npm install prompt-history

Usage

History can only be used with "text" prompts. This will not work with checkbox, list, radio prompts, etc.

var Prompt = require('prompt-base');
var history = require('prompt-history');

// pass the prompt instance to "history()"
var prompt = history(new Prompt({
  name: 'number',
  message: 'Favorite number?',
}));

prompt.run()
  .then(function(answer) {
    console.log({number: answer});
  })
  .catch(console.log)

How it works

  • tab+shift to go through previous answers, starting with most recent
  • tab+shift to go in reverse

Options

options.historyLimit

Limit the number of answers to persist in the history array.

Type: number

Default: Infinity

Example

var prompt = history(new Prompt({
  name: 'number',
  message: 'Favorite number?',
  historyLimit: 10
}));

options.path

Required: Customize the filepath for the persisted history store.

Type: string

Default: ~/.data-store/prompt-history.json

Example

var path = require('path');
var prompt = history(new Prompt({
  name: 'number',
  message: 'Favorite number?',
  path: path.join(__dirname, 'custom-store-path.json')
}));

options.store

Pass a custom instance of data-store for persisting answers.

Type: object

Default: instance of data-store

Example

var Store = require('data-store');
var store = new Store('custom-name');

var prompt = history(new Prompt({
  name: 'number',
  message: 'Favorite number?',
  store: store
}));

See data-store for all available features and options.

About

Related projects

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Please read the contributing guide for advice on opening issues, pull requests, and coding standards.

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

Author

Brian Woodward

License

Copyright © 2017, Brian Woodward. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on June 04, 2017.

1.0.1

7 years ago

1.0.0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago