A collection of common interactive command line user interfaces.
Installations
npm install @inquirer/figures
Developer Guide
Typescript
Yes
Module System
ESM
Min. Node Version
>=18
Node Version
22.13.0
NPM Version
lerna/8.1.9/node@v22.13.0+arm64 (darwin)
Score
99.1
Supply Chain
67.6
Quality
92
Maintenance
100
Vulnerability
100
License
Releases
inquirer@12.3.3
Published on 28 Jan 2025
@inquirer/core@10.1.5
Published on 28 Jan 2025
inquirer@12.3.0
Published on 20 Dec 2024
@inquirer/confirm@5.1.0
Published on 07 Dec 2024
@inquirer/editor@4.2.0
Published on 07 Dec 2024
@inquirer/input@4.1.0
Published on 07 Dec 2024
Contributors
Languages
TypeScript (91.61%)
JavaScript (8.39%)
Developer
SBoudrias
Download Statistics
Total Downloads
131,320,217
Last Day
1,191,551
Last Week
5,223,521
Last Month
21,840,979
Last Year
131,320,217
GitHub Statistics
20,501 Stars
1,676 Commits
1,307 Forks
148 Watching
9 Branches
207 Contributors
Package Meta Information
Latest Version
1.0.10
Package Id
@inquirer/figures@1.0.10
Unpacked Size
48.58 kB
Size
5.78 kB
File Count
8
NPM Version
lerna/8.1.9/node@v22.13.0+arm64 (darwin)
Node Version
22.13.0
Publised On
28 Jan 2025
Total Downloads
Cumulative downloads
Total Downloads
131,320,217
Last day
1.1%
1,191,551
Compared to previous day
Last week
-10.8%
5,223,521
Compared to previous week
Last month
16.7%
21,840,979
Compared to previous month
Last year
0%
131,320,217
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
3
Inquirer
A collection of common interactive command line user interfaces.
Give it a try in your own terminal!
1npx @inquirer/demo@latest
Special Thanks
Warp, the intelligent terminal for developers
Inquirer's terminal of choice!
Available for MacOS and Linux
Installation
npm | yarn |
---|---|
|
|
[!NOTE] Inquirer recently underwent a rewrite from the ground up to reduce the package size and improve performance. The previous version of the package is still maintained (though not actively developed), and offered hundreds of community contributed prompts that might not have been migrated to the latest API. If this is what you're looking for, the previous package is over here.
Usage
1import { input } from '@inquirer/prompts'; 2 3const answer = await input({ message: 'Enter your name' });
Prompts
Input
1import { input } from '@inquirer/prompts';
See documentation for usage example and options documentation.
Select
1import { select } from '@inquirer/prompts';
See documentation for usage example and options documentation.
Checkbox
1import { checkbox } from '@inquirer/prompts';
See documentation for usage example and options documentation.
Confirm
1import { confirm } from '@inquirer/prompts';
See documentation for usage example and options documentation.
Search
1import { search } from '@inquirer/prompts';
See documentation for usage example and options documentation.
Password
1import { password } from '@inquirer/prompts';
See documentation for usage example and options documentation.
Expand
1import { expand } from '@inquirer/prompts';
See documentation for usage example and options documentation.
Editor
Launches an instance of the users preferred editor on a temporary file. Once the user exits their editor, the content of the temporary file is read as the answer. The editor used is determined by reading the $VISUAL or $EDITOR environment variables. If neither of those are present, the OS default is used (notepad on Windows, vim on Mac or Linux.)
1import { editor } from '@inquirer/prompts';
See documentation for usage example and options documentation.
Number
Very similar to the input
prompt, but with built-in number validation configuration option.
1import { number } from '@inquirer/prompts';
See documentation for usage example and options documentation.
Raw List
1import { rawlist } from '@inquirer/prompts';
See documentation for usage example and options documentation.
Create your own prompts
The API documentation is over here, and our testing utilities here.
Advanced usage
All inquirer prompts are a function taking 2 arguments. The first argument is the prompt configuration (unique to each prompt). The second is providing contextual or runtime configuration.
The context options are:
Property | Type | Required | Description |
---|---|---|---|
input | NodeJS.ReadableStream | no | The stdin stream (defaults to process.stdin ) |
output | NodeJS.WritableStream | no | The stdout stream (defaults to process.stdout ) |
clearPromptOnDone | boolean | no | If true, we'll clear the screen after the prompt is answered |
signal | AbortSignal | no | An AbortSignal to cancel prompts asynchronously |
Example:
1import { confirm } from '@inquirer/prompts'; 2 3const allowEmail = await confirm( 4 { message: 'Do you allow us to send you email?' }, 5 { 6 output: new Stream.Writable({ 7 write(chunk, _encoding, next) { 8 // Do something 9 next(); 10 }, 11 }), 12 clearPromptOnDone: true, 13 }, 14);
Canceling prompt
This can preferably be done with either an AbortController
or AbortSignal
.
1// Example 1: using built-in AbortSignal utilities 2import { confirm } from '@inquirer/prompts'; 3 4const answer = await confirm({ ... }, { signal: AbortSignal.timeout(5000) });
1// Example 1: implementing custom cancellation logic 2import { confirm } from '@inquirer/prompts'; 3 4const controller = new AbortController(); 5setTimeout(() => { 6 controller.abort(); // This will reject the promise 7}, 5000); 8 9const answer = await confirm({ ... }, { signal: controller.signal });
Alternatively, all prompt functions are returning a cancelable promise. This special promise type has a cancel
method that'll cancel and cleanup the prompt.
On calling cancel
, the answer promise will become rejected.
1import { confirm } from '@inquirer/prompts'; 2 3const promise = confirm(...); // Warning: for this pattern to work, `await` cannot be used. 4 5promise.cancel();
Recipes
Handling ctrl+c
gracefully
When a user press ctrl+c
to exit a prompt, Inquirer rejects the prompt promise. This is the expected behavior in order to allow your program to teardown/cleanup its environment. When using async/await
, rejected promises throw their error. When unhandled, those errors print their stack trace in your user's terminal.
ExitPromptError: User force closed the prompt with 0 null
at file://example/packages/core/dist/esm/lib/create-prompt.js:55:20
at Emitter.emit (file://example/node_modules/signal-exit/dist/mjs/index.js:67:19)
at #processEmit (file://example/node_modules/signal-exit/dist/mjs/index.js:236:27)
at #process.emit (file://example/node_modules/signal-exit/dist/mjs/index.js:187:37)
at process.callbackTrampoline (node:internal/async_hooks:130:17)
This isn't a great UX, which is why we highly recommend you to handle those errors gracefully.
First option is to wrap your scripts in try/catch
; like we do in our demo program. Or handle the error in your CLI framework mechanism; for example Clipanion catch
method.
Lastly, you could handle the error globally with an event listener and silence it.
1process.on('uncaughtException', (error) => { 2 if (error instanceof Error && error.name === 'ExitPromptError') { 3 console.log('š until next time!'); 4 } else { 5 // Rethrow unknown errors 6 throw error; 7 } 8});
Get answers in an object
When asking many questions, you might not want to keep one variable per answer everywhere. In which case, you can put the answer inside an object.
1import { input, confirm } from '@inquirer/prompts'; 2 3const answers = { 4 firstName: await input({ message: "What's your first name?" }), 5 allowEmail: await confirm({ message: 'Do you allow us to send you email?' }), 6}; 7 8console.log(answers.firstName);
Ask a question conditionally
Maybe some questions depend on some other question's answer.
1import { input, confirm } from '@inquirer/prompts'; 2 3const allowEmail = await confirm({ message: 'Do you allow us to send you email?' }); 4 5let email; 6if (allowEmail) { 7 email = await input({ message: 'What is your email address' }); 8}
Get default value after timeout
1import { input } from '@inquirer/prompts'; 2 3const answer = await input( 4 { message: 'Enter a value (timing out in 5 seconds)' }, 5 { signal: AbortSignal.timeout(5000) }, 6).catch((error) => { 7 if (error.name === 'AbortPromptError') { 8 return 'Default value'; 9 } 10 11 throw error; 12});
Using as pre-commit/git hooks, or scripts
By default scripts ran from tools like husky
/lint-staged
might not run inside an interactive shell. In non-interactive shell, Inquirer cannot run, and users cannot send keypress events to the process.
For it to work, you must make sure you start a tty
(or "interactive" input stream.)
If those scripts are set within your package.json
, you can define the stream like so:
1 "precommit": "my-script < /dev/tty"
Or if in a shell script file, you'll do it like so: (on Windows that's likely your only option)
1#!/bin/sh 2exec < /dev/tty 3 4node my-script.js
Using with nodemon
When using inquirer prompts with nodemon, you need to pass the --no-stdin
flag for everything to work as expected.
1npx nodemon ./packages/demo/demos/password.mjs --no-stdin
Note that for most of you, you'll be able to use the new watch-mode built-in Node. This mode works out of the box with inquirer.
1# One of depending on your need 2node --watch script.js 3node --watch-path=packages/ packages/demo/
Wait for config
Maybe some question configuration require to await a value.
1import { confirm } from '@inquirer/prompts'; 2 3const answer = await confirm({ message: await getMessage() });
Community prompts
If you created a cool prompt, send us a PR adding it to the list below!
Interactive List Prompt
Select a choice either with arrow keys + Enter or by pressing a key associated with a choice.
? Choose an option:
> Run command (D)
Quit (Q)
Action Select Prompt
Choose an item from a list and choose an action to take by pressing a key.
? Choose a file Open <O> Edit <E> Delete <X>
āÆ image.png
audio.mp3
code.py
Table Multiple Prompt
Select multiple answer from a table display.
1Choose between choices? (Press <space> to select, <Up and Down> to move rows, 2<Left and Right> to move columns) 3 4āāāāāāāāāāāā¬āāāāāāāā¬āāāāāāāā 5ā 1-2 of 2 ā Yes? ā No? | 6āāāāāāāāāāāā¼āāāāāāāā¼āāāāāāāā¤ 7ā Choice 1 ā [ āÆ ] ā āÆ | 8āāāāāāāāāāāā¼āāāāāāāā¼āāāāāāāā¤ 9ā Choice 2 ā āÆ ā āÆ | 10āāāāāāāāāāāā“āāāāāāāā“āāāāāāāā 11
Toggle Prompt
Confirm with a toggle. Select a choice with arrow keys + Enter.
? Do you want to continue? no / yes
Sortable Checkbox Prompt
The same as built-in checkbox prompt, but also allowing to reorder choices using ctrl+up/down.
? Which PRs and in what order would you like to merge? (Press <space> to select, <a> to toggle all, <i> to invert selection, <ctrl+up> to move item up, <ctrl+down> to move item down, and <enter> to proceed)
āÆ āÆ PR 1
āÆ PR 2
āÆ PR 3
An inquirer select that supports multiple selections and filtering/searching.
? Choose your OS, IDE, PL, etc. (Press <tab> to select/deselect, <backspace> to remove selected
option, <enter> to select option)
>> vue
>[ ] vue
[ ] vuejs
[ ] fuelphp
[ ] venv
[ ] vercel
(Use arrow keys to reveal more options)
File Selector Prompt
A file selector, you can navigate freely between directories, choose what type of files you want to allow and it is fully customizable.
1? Select a file: 2/main/path/ 3āāā folder1/ 4āāā folder2/ 5āāā folder3/ 6āāā file1.txt 7āāā file2.pdf 8āāā file3.jpg (not allowed) 9āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā 10Use āā to navigate through the list 11Press <esc> to navigate to the parent directory 12Press <enter> to select a file or navigate to a directory
License
Copyright (c) 2023 Simon Boudrias (twitter: @vaxilart)
Licensed under the MIT license.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
30 commit(s) and 15 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
- Info: security policy file detected: SECURITY.md:1
- Info: Found linked content: SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1
- Info: Found text in security policy: SECURITY.md:1
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
SAST tool detected but not run on all commits
Details
- Info: SAST configuration detected: CodeQL
- Warn: 18 commits out of 19 are checked with a SAST tool
Reason
1 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:24
- Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:23
- Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
Found 1/18 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/codeql-analysis.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/codeql-analysis.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/codeql-analysis.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:47: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:70: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:72: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:78: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:91: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:93: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:99: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:115: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:117: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:123: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:159: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:161: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:167: update your workflow using https://app.stepsecurity.io/secureworkflow/SBoudrias/Inquirer.js/main.yml/main?enable=pin
- Info: 0 out of 20 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
Score
6
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to @inquirer/figures
inquirer-figures-gacrux-jekyll
Adexe Created Npm Publish store to check for the client purpose Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
slides-local-inquirer-figures
Adexe Created Npm Publish store to check for the client purpose Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
polaris-inquirer-hexo-figures
Adexe Created Npm Publish store to check for the client purpose Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
impulse-figures-inquirer-oortcloud
Adexe Created Npm Publish store to check for the client purpose Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris