https://github.com/enquirer/prompt-history
This repository has been archived, use the built-in history functionality in Enquirer instead.
https://github.com/enquirer/prompt-history
answers enquirer history persist prompt store tab
Last synced: 8 months ago
JSON representation
This repository has been archived, use the built-in history functionality in Enquirer instead.
- Host: GitHub
- URL: https://github.com/enquirer/prompt-history
- Owner: enquirer
- License: mit
- Created: 2017-03-13T20:23:30.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-05T00:32:44.000Z (over 8 years ago)
- Last Synced: 2025-03-24T11:13:06.926Z (9 months ago)
- Topics: answers, enquirer, history, persist, prompt, store, tab
- Language: JavaScript
- Homepage: https://github.com/enquirer/enquirer
- Size: 2.55 MB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/contributing.md
- License: LICENSE
Awesome Lists containing this project
README
# prompt-history [](https://www.npmjs.com/package/prompt-history) [](https://npmjs.org/package/prompt-history) [](https://npmjs.org/package/prompt-history)
> Tab through previous answer history.
**Persist answers**

**Tab through answer history**

## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install prompt-history
```
## Usage
History can only be used with "text" prompts. This will not work with checkbox, list, radio prompts, etc.
```js
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**
```js
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**
```js
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](https://github.com/jonschlinkert/data-store) for persisting answers.
**Type**: `object`
**Default**: instance of data-store
**Example**
```js
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](https://github.com/jonschlinkert/data-store) for all available features and options.
## About
### Related projects
* [enquirer](https://www.npmjs.com/package/enquirer): Intuitive, plugin-based prompt system for node.js. | [homepage](http://enquirer.io "Intuitive, plugin-based prompt system for node.js.")
* [prompt-base](https://www.npmjs.com/package/prompt-base): Base prompt module used for creating custom prompts. | [homepage](https://github.com/enquirer/prompt-base "Base prompt module used for creating custom prompts.")
* [prompt-password](https://www.npmjs.com/package/prompt-password): Password prompt. Can be used as a standalone prompt, or as a plugin for [Enquirer](http://enquirer.io). | [homepage](https://github.com/enquirer/prompt-password "Password prompt. Can be used as a standalone prompt, or as a plugin for [Enquirer].")
* [prompt-text](https://www.npmjs.com/package/prompt-text): Basic text input prompt. This can be used standalone, but it's also included in [enquirer… [more](https://github.com/enquirer/prompt-text) | [homepage](https://github.com/enquirer/prompt-text "Basic text input prompt. This can be used standalone, but it's also included in [enquirer] by default.")
### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
Please read the [contributing guide](.github/contributing.md) 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:
```sh
$ npm install && npm test
```
### Author
**Brian Woodward**
* [github/doowb](https://github.com/doowb)
* [twitter/doowb](https://twitter.com/doowb)
### License
Copyright © 2017, [Brian Woodward](https://github.com/doowb).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on June 04, 2017._