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!
npm install inquirerer
- 🖊 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.
To install the library, use npm
or yarn
:
npm install inquirerer
Import the library and use it to create prompts for your command-line application:
import { Inquirerer } from 'inquirerer';
Here are several examples of different question types you can use:
{
type: 'text',
name: 'firstName',
message: 'Enter your first name',
}
{
type: 'confirm',
name: 'continue',
message: 'Do you wish to continue?',
default: true,
}
{
type: 'autocomplete',
name: 'fruitChoice',
message: 'Select your favorite fruit',
options: [
'Apple', 'Banana', 'Cherry'
],
maxDisplayLines: 5
}
{
type: 'checkbox',
name: 'techStack',
message: 'Choose your tech stack',
options: [
'Node.js', 'React', 'Angular', 'Vue.js'
],
returnFullResults: false,
required: true
}
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();
When first cloning the repo:
yarn
yarn build
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.