1.0.0-3.0 • Published 2 years ago

inquirer-selectable-table v1.0.0-3.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

inquirer-selectable-table npm version

A selectable table-like prompt for Inquirer.js

Screenshot of output

Screen capture of the selectable table prompt

Installation

npm install --save inquirer-selectable-table

Usage

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

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

inquirer.registerPrompt("table", require("inquirer-selectable-table"));

inquirer
  .prompt([
    {
      type: "table",
      name: "people",
      message: "Choose your person of the week",
      columns: [
        {
          name: "firstName",
          value: "firstName"
        },
        {
          name: "lastName",
          value: "lastName"
        },
        {
          name: "location",
          value: "location"
        }
      ],
      rows: [
           {
          firstName: "Abel",
         lastName:"Nazeh",
         location:"Nigeria"
        },
        {
          firstName: "Daniel",
         lastName:"Ruiz",
         location:"Spain"
        },
            {
          firstName: "John",
         lastName:"Doe",
         location:"Leaf Village"
        },
               {
          firstName: "Kakashi",
         lastName:"Hatake",
         location:"Leaf Village"
        },
      ]
    }
  ])
  .then(answers => {
  
    console.log(answers);
  });

Options

  • columns: Array of options to display as columns. Follows the same format as Inquirer's choices
  • rows: Array of options to display as rows. Follows the same format as Inquirer's choices
  • pageSize: Number of rows to display per page