|
| 1 | +# inquirerer |
| 2 | + |
| 3 | +<p align="center" width="100%"> |
| 4 | + <img height="90" src="https://user-images.githubusercontent.com/545047/190171475-b416f99e-2831-4786-9ba3-a7ff4d95b0d3.svg" /> |
| 5 | +</p> |
| 6 | + |
| 7 | +<p align="center" width="100%"> |
| 8 | + |
| 9 | + <a href="https://github.com/pyramation/inquirerer/actions/workflows/run-tests.yml"> |
| 10 | + <img height="20" src="https://github.com/pyramation/inquirerer/actions/workflows/run-tests.yml/badge.svg" /> |
| 11 | + </a> |
| 12 | + <a href="https://github.com/pyramation/inquirerer/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"></a> |
| 13 | + <a href="https://www.npmjs.com/package/inquirerer"><img height="20" src="https://img.shields.io/npm/dt/inquirerer"></a> |
| 14 | + <a href="https://www.npmjs.com/package/inquirerer"><img height="20" src="https://img.shields.io/github/package-json/v/pyramation/inquirerer?filename=packages%2Finquirerer%2Fpackage.json"></a> |
| 15 | +</p> |
| 16 | + |
| 17 | +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. |
| 18 | + |
| 19 | +## Install |
| 20 | + |
| 21 | +```sh |
| 22 | +npm install inquirerer |
| 23 | +``` |
| 24 | + |
| 25 | +## Features |
| 26 | + |
| 27 | +- 🖊 **Multiple Question Types:** Support for text, autocomplete, checkbox, and confirm questions. |
| 28 | +- 🛠 **Customizable Prompts:** Easily configure prompts to include default values, requirement flags, and custom validation rules. |
| 29 | +- 🔎 **Interactive Autocomplete:** Dynamically filter options based on user input. |
| 30 | +- ✔️ **Flexible Checkbox Selections:** Allow users to select multiple options from a list. |
| 31 | + |
| 32 | +## Table of Contents |
| 33 | + |
| 34 | +- [Introduction](#inquirerer) |
| 35 | + - [Install](#install) |
| 36 | +- [Features](#features) |
| 37 | +- [Installation](#installation) |
| 38 | +- [Usage](#usage) |
| 39 | + - [Example Questions](#example-questions) |
| 40 | + - [Text Question](#text-question) |
| 41 | + - [Confirm Question](#confirm-question) |
| 42 | + - [Autocomplete Question](#autocomplete-question) |
| 43 | + - [Checkbox Question](#checkbox-question) |
| 44 | + - [Executing a Prompt](#executing-a-prompt) |
| 45 | +- [Developing](#developing) |
| 46 | +- [Credits](#credits) |
| 47 | +- [Disclaimer](#disclaimer) |
| 48 | + |
| 49 | +## Installation |
| 50 | + |
| 51 | +To install the library, use `npm` or `yarn`: |
| 52 | + |
| 53 | +```bash |
| 54 | +npm install inquirerer |
| 55 | +``` |
| 56 | + |
| 57 | +## Usage |
| 58 | + |
| 59 | +Import the library and use it to create prompts for your command-line application: |
| 60 | + |
| 61 | +```js |
| 62 | +import { Inquirerer } from 'inquirerer'; |
| 63 | +``` |
| 64 | + |
| 65 | +### Example Questions |
| 66 | + |
| 67 | +Here are several examples of different question types you can use: |
| 68 | + |
| 69 | +#### Text Question |
| 70 | + |
| 71 | +```js |
| 72 | +{ |
| 73 | + type: 'text', |
| 74 | + name: 'firstName', |
| 75 | + message: 'Enter your first name', |
| 76 | +} |
| 77 | +``` |
| 78 | + |
| 79 | +#### Confirm Question |
| 80 | + |
| 81 | +```js |
| 82 | +{ |
| 83 | + type: 'confirm', |
| 84 | + name: 'continue', |
| 85 | + message: 'Do you wish to continue?', |
| 86 | + default: true, |
| 87 | +} |
| 88 | +``` |
| 89 | + |
| 90 | +#### Autocomplete Question |
| 91 | + |
| 92 | +```js |
| 93 | +{ |
| 94 | + type: 'autocomplete', |
| 95 | + name: 'fruitChoice', |
| 96 | + message: 'Select your favorite fruit', |
| 97 | + options: [ |
| 98 | + 'Apple', 'Banana', 'Cherry' |
| 99 | + ], |
| 100 | + maxDisplayLines: 5 |
| 101 | +} |
| 102 | +``` |
| 103 | + |
| 104 | +#### Checkbox Question |
| 105 | + |
| 106 | +```js |
| 107 | +{ |
| 108 | + type: 'checkbox', |
| 109 | + name: 'techStack', |
| 110 | + message: 'Choose your tech stack', |
| 111 | + options: [ |
| 112 | + 'Node.js', 'React', 'Angular', 'Vue.js' |
| 113 | + ], |
| 114 | + returnFullResults: false, |
| 115 | + required: true |
| 116 | +} |
| 117 | +``` |
| 118 | + |
| 119 | +### Executing a Prompt |
| 120 | + |
| 121 | +To run a prompt and handle the response: |
| 122 | + |
| 123 | +```js |
| 124 | +const prompter = new Inquirerer(); |
| 125 | + |
| 126 | +async function runPrompt() { |
| 127 | + const responses = await prompter.prompt({}, [ |
| 128 | + { |
| 129 | + type: 'text', |
| 130 | + name: 'lastName', |
| 131 | + message: 'Enter your last name', |
| 132 | + required: true |
| 133 | + }, |
| 134 | + { |
| 135 | + type: 'checkbox', |
| 136 | + name: 'devTools', |
| 137 | + message: 'Select development tools:', |
| 138 | + options: ['VS Code', 'Sublime', 'Atom'], |
| 139 | + required: true |
| 140 | + } |
| 141 | + ]); |
| 142 | + |
| 143 | + console.log(responses); |
| 144 | +} |
| 145 | + |
| 146 | +runPrompt(); |
| 147 | +``` |
| 148 | + |
| 149 | + |
| 150 | +## Developing |
| 151 | + |
| 152 | + |
| 153 | +When first cloning the repo: |
| 154 | +``` |
| 155 | +yarn |
| 156 | +yarn build |
| 157 | +``` |
| 158 | + |
| 159 | +## Disclaimer |
| 160 | + |
| 161 | +AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. |
| 162 | + |
| 163 | +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. |
0 commit comments