0.0.1 • Published 3 years ago

inquirer-multi-choice v0.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

inquirer-multi-choice npm version

A multiple choice prompt for Inquirer.js

Screen capture of the table prompt

Installation

npm install --save inquirer-multi-choice

Usage

After registering the prompt, set any question to have type: "mutli-choice" to make use of this prompt.

The result will be an array, containing the value for each row.

inquirer.registerPrompt('multi-choice', require('inquirer-multi-choice'));

inquirer
  .prompt([
    {
      type: 'multi-choice',
      name: 'settings',
      message: 'Change settings',
      rows: [
        {
          name: 'Enabled',
          choices: ['on', 'off'],
        },
        {
          name: 'Color',
          choices: [
            {
              name: 'red',
              value: '#f00',
            },
            {
              name: 'green',
              value: '#0f0',
            },
            {
              name: 'blue',
              value: '#00f',
            },
          ],
        },
        {
          name: 'Log',
          default: 'false',
          choices: ['true', 'false'],
        },
      ],
    },
  ])
  .then((answers) => {
    console.log(answers);
    /*
      {
        settings: {
          Enabled: 'on',
          Color: 'red',
          Log: 'true'
        }
      }
    */
  });

Options

  • rows: Array of objects. Follows the same format as Inquirer's choices