1. inquirer-table-prompt
A table-like prompt for Inquirer
inquirer-table-prompt
Package: inquirer-table-prompt
Created by: eduardoboucas
Last modified: Thu, 05 May 2022 23:21:01 GMT
Version: 0.2.1
License: ISC
Downloads: 7,259
Repository: https://github.com/eduardoboucas/inquirer-table-prompt

Install

npm install inquirer-table-prompt
yarn add inquirer-table-prompt

inquirer-table-prompt npm version

A table-like prompt for Inquirer.js

Screen capture of the table prompt

Installation

npm install --save inquirer-table-prompt

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("./index"));

inquirer
  .prompt([
    {
      type: "table",
      name: "workoutPlan",
      message: "Choose your workout plan for next week",
      columns: [
        {
          name: "Arms",
          value: "arms"
        },
        {
          name: "Legs",
          value: "legs"
        },
        {
          name: "Cardio",
          value: "cardio"
        },
        {
          name: "None",
          value: undefined
        }
      ],
      rows: [
        {
          name: "Monday",
          value: 0
        },
        {
          name: "Tuesday",
          value: 1
        },
        {
          name: "Wednesday",
          value: 2
        },
        {
          name: "Thursday",
          value: 3
        },
        {
          name: "Friday",
          value: 4
        },
        {
          name: "Saturday",
          value: 5
        },
        {
          name: "Sunday",
          value: 6
        }
      ]
    }
  ])
  .then(answers => {
    /*
    { workoutPlan:
      [ 'arms', 'legs', 'cardio', undefined, 'legs', 'arms', undefined ] }    
    */
    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

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin