Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/enquirer/prompt-grid
Prompt that allows the user to re-arrange the cells in a grid in the terminal. This can be used for configuration for layouts, tables, HTML grids, etc.
https://github.com/enquirer/prompt-grid
command-line enquirer grid prompt prompts question terminal
Last synced: about 2 months ago
JSON representation
Prompt that allows the user to re-arrange the cells in a grid in the terminal. This can be used for configuration for layouts, tables, HTML grids, etc.
- Host: GitHub
- URL: https://github.com/enquirer/prompt-grid
- Owner: enquirer
- License: mit
- Created: 2017-05-26T06:48:09.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-05-26T15:16:22.000Z (over 7 years ago)
- Last Synced: 2024-03-25T19:59:29.405Z (10 months ago)
- Topics: command-line, enquirer, grid, prompt, prompts, question, terminal
- Language: JavaScript
- Homepage: https://github.com/enquirer
- Size: 59.6 KB
- Stars: 7
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# prompt-grid [![NPM version](https://img.shields.io/npm/v/prompt-grid.svg?style=flat)](https://www.npmjs.com/package/prompt-grid) [![NPM monthly downloads](https://img.shields.io/npm/dm/prompt-grid.svg?style=flat)](https://npmjs.org/package/prompt-grid) [![NPM total downloads](https://img.shields.io/npm/dt/prompt-grid.svg?style=flat)](https://npmjs.org/package/prompt-grid)
> Prompt that allows the user to re-arrange the cells in a grid in the terminal.
![prompt-grid example](https://raw.githubusercontent.com/enquirer/prompt-grid/master/example.gif)
If you like this project please consider starring it.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save prompt-grid
```## Usage
Pass an array of choices to create a grid:
```js
var Prompt = require('./');
var prompt = new Prompt({
name: 'letters',
message: 'Re-order cells',
choices: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']
});// run as async
prompt.ask(function(answer) {
console.log(answer);
});// run as promise
prompt.run()
.then(function(answer) {
console.log(answer);
});
```## Enquirer usage
Register the prompt as a plugin with [enquirer](https://github.com/enquirer/enquirer):
```js
var Enquirer = require('enquirer');
var enquirer = new Enquirer();enquirer.register('readme', require('prompt-grid'));
```### Enquirer example
[Enquirer](https://github.com/enquirer/enquirer) supports either the declarative object-oriented (inquirer-style) question format or a more expressive format using the `.question` method.
**Declarative**
Inquirer-style declarative format (takes an array or object):
```js
var questions = [
{
name: 'letters',
type: 'grid',
message: 'Hold shift+(up|right|down|left) to re-arrange cells',
choices: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']
}
];enquirer.ask(questions)
.then(function(answers) {
console.log(answers)
});
```**Expressive**
Pre-define questions and easily compose prompts by passing the name(s) of the prompts to run:
```js
enquirer.question('letters', {
type: 'grid',
message: 'Hold shift+(up|right|down|left) to re-arrange cells',
choices: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']
});enquirer
.prompt(['letters'])
.then(function(answers) {
console.log(answers)
});
```## About
### Related projects
* [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-checkbox](https://www.npmjs.com/package/prompt-checkbox): Multiple-choice/checkbox prompt. Can be used standalone or with a prompt system like [Enquirer](https://github.com/enquirer/enquirer). | [homepage](https://github.com/enquirer/prompt-checkbox "Multiple-choice/checkbox prompt. Can be used standalone or with a prompt system like [Enquirer].")
* [prompt-password](https://www.npmjs.com/package/prompt-password): Password prompt. Can be used as a standalone prompt, or with a prompt system like… [more](https://github.com/enquirer/prompt-password) | [homepage](https://github.com/enquirer/prompt-password "Password prompt. Can be used as a standalone prompt, or with a prompt system like [Enquirer].")
* [prompt-sort](https://www.npmjs.com/package/prompt-sort): Prompt that allows the user to re-order items in a list of choices. | [homepage](https://github.com/enquirer/prompt-sort "Prompt that allows the user to re-order items in a list of choices.")### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
### 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 May 26, 2017._