1.9.0 β€’ Published 2 days ago

inquirerer v1.9.0

Weekly downloads
6
License
SEE LICENSE IN LI...
Repository
github
Last release
2 days ago

inquirerer

This library is designed to facilitate the creation of command-line utilities by providing a robust framework for capturing user input through interactive prompts. It supports a variety of question types, making it highly flexible and suitable for a wide range of applications.

This is the new and improved version of pyramation/inquirer. Soon this will completely replace it!

Install

npm install inquirerer

Features

  • πŸ–Š Multiple Question Types: Support for text, autocomplete, checkbox, and confirm questions.
  • πŸ›  Customizable Prompts: Easily configure prompts to include default values, requirement flags, and custom validation rules.
  • πŸ”Ž Interactive Autocomplete: Dynamically filter options based on user input.
  • βœ”οΈ Flexible Checkbox Selections: Allow users to select multiple options from a list.

Table of Contents

Installation

To install the library, use npm or yarn:

npm install inquirerer

Usage

Import the library and use it to create prompts for your command-line application:

import { Inquirerer } from 'inquirerer';

Example Questions

Here are several examples of different question types you can use:

Text Question

{
  type: 'text',
  name: 'firstName',
  message: 'Enter your first name',
}

Confirm Question

{
  type: 'confirm',
  name: 'continue',
  message: 'Do you wish to continue?',
  default: true,
}

Autocomplete Question

{
  type: 'autocomplete',
  name: 'fruitChoice',
  message: 'Select your favorite fruit',
  options: [
    'Apple', 'Banana', 'Cherry'
  ],
  maxDisplayLines: 5
}

Checkbox Question

{
  type: 'checkbox',
  name: 'techStack',
  message: 'Choose your tech stack',
  options: [
    'Node.js', 'React', 'Angular', 'Vue.js'
  ],
  returnFullResults: false,
  required: true
}

Executing a Prompt

To run a prompt and handle the response:

const prompter = new Inquirerer();

async function runPrompt() {
  const responses = await prompter.prompt({}, [
    {
      type: 'text',
      name: 'lastName',
      message: 'Enter your last name',
      required: true
    },
    {
      type: 'checkbox',
      name: 'devTools',
      message: 'Select development tools:',
      options: ['VS Code', 'Sublime', 'Atom'],
      required: true
    }
  ]);

  console.log(responses);
}

runPrompt();

Developing

When first cloning the repo:

yarn
yarn build

Disclaimer

AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED β€œAS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.

No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.