Socket
Book a DemoInstallSign in
Socket

inquirer-select-with-state

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inquirer-select-with-state

Inquirer select prompt with a stateful banner

0.1.3
latest
Source
npmnpm
Version published
Weekly downloads
5
-44.44%
Maintainers
1
Weekly downloads
 
Created
Source

inquirer-select-with-state

Inquirer select prompt with a stateful banner

A fork of inquirer's built-in select command line prompt, but with the ability to add a stateful banner above the list of choices.

You provide a statefulBanner function. This function receives a setState function which can be called at will. The string sent to setState is shown above the select prompt. statefulBanner can also return a cleanup function.

Install

pnpm add inquirer-select-with-state
yarn add inquirer-select-with-state
npm add inquirer-select-with-state

Usage

import select from 'inquirer-select-with-state'

const answer = await select({
    message: 'Choose an option',
    choices: [
        { name: '1', value: '1' },
        { name: '2', value: '2' },
        { name: '3', value: '3' },
    ],
    statefulBanner: (setState: (s: string) => void) => {
        setState('Directory size: loading...')
        exec('du -sh', (err, stdout) => {
            if (!err) {
                setState(`Directory size: ${stdout}`)
            }
        })
    },
})

The prompt will initially look like this:

Directory size: loading...
? Choose an option
❯ 1
  2
  3

A moment later, it will automatically update:

Directory size: 123M
? Choose an option
❯ 1
  2
  3

Return value

If your banner has any side effects (e.g. timeouts), you can return a cleanup function which will be called when the prompt quits.

Example

See src/example.ts for a full example using async/await.

Keywords

inquirer

FAQs

Package last updated on 29 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.