Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@biggerstar/inquirer-selectable-table

biggerstar249ISC1.0.12TypeScript support: included

修改自 inquirer-selectable-table, 无内边框版本

inquirer, cli, prompt, table, selectable

readme

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 @biggerstar/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