Skip to content

fishballapp/inquirer-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@inquirer-cli

CI npm License: MIT

Interactive command-line prompts for shell scripts, powered by Inquirer.js.

The @inquirer-cli suite lets you add interactive prompts (text input, confirmations, selections, and more) to any shell script - no JavaScript required.

Quick Start

No installation needed. Run any prompt directly with npx:

name=$(npx -y @inquirer-cli/input "What is your name?")
echo "Hello, $name!"

Why -y? The -y flag auto-confirms the npx install prompt. Without it, the confirmation prompt would interfere when capturing output with $().

How It Works

Each prompt renders its UI to stderr and writes the user's answer to stdout. This means you can capture the answer with $() while the prompt remains visible in the terminal.

Prompts

Prompts for free-text input.

name=$(npx -y @inquirer-cli/input -r "What is your name?")
echo "Hello, $name!"
Option Description
<message> The prompt message (required)
-r, --required Reject empty input
-h, --help Show help

Prompts for numeric input.

age=$(npx -y @inquirer-cli/number -r "Enter your age")
echo "You are $age years old."
Option Description
<message> The prompt message (required)
-r, --required Reject empty input
-h, --help Show help

Prompts for a yes/no confirmation. Outputs true or false.

if $(npx -y @inquirer-cli/confirm "Do you want to continue?"); then
  echo "Proceeding..."
else
  echo "Operation cancelled."
fi
Option Description
<message> The prompt message (required)
-y, --yes Default to "yes" instead of "no"
-h, --help Show help

Prompts the user to pick one option from a list.

fruit=$(npx -y @inquirer-cli/select -c Apple -c Banana -c Cherry "Pick a fruit")
echo "You selected: $fruit"
Option Description
<message> The prompt message (required)
-c, --choice <value> Add a choice (use multiple times, at least one required)
-r, --required Reject empty selection
-h, --help Show help

Prompts the user to select multiple options from a list. Outputs selected values as a space-separated string.

colors=$(npx -y @inquirer-cli/checkbox -r "Select your favorite colors" -c Red -c Blue -c Green)
echo "You selected:"
for color in $colors; do
  echo "- $color"
done
Option Description
<message> The prompt message (required)
-c, --choice <value> Add a choice (use multiple times, at least one required)
-r, --required Require at least one selection
-h, --help Show help

Prompts for sensitive input with masking.

secret=$(npx -y @inquirer-cli/password -r "Enter your password")
Option Description
<message> The prompt message (required)
-r, --required Reject empty input
-h, --help Show help

@inquirer-cli/editor (not supported yet)

Opens the user's default editor for multi-line input. This package is currently not functional due to technical difficulties. Contributions welcome!

notes=$(npx -y @inquirer-cli/editor "Write your notes")
echo "Your notes: $notes"

Full Example

#!/bin/sh

name=$(npx -y @inquirer-cli/input -r "What is your name?")
age=$(npx -y @inquirer-cli/number -r "How old are you?")
lang=$(npx -y @inquirer-cli/select -c JavaScript -c Python -c Go "Favorite language?")

if $(npx -y @inquirer-cli/confirm "Save profile?"); then
  echo "Saved: $name, age $age, likes $lang"
fi

Requirements

  • Node.js >= 20.12.0

Author

@ycmjason

License

MIT


@inquirer-cli is an independent project and is not affiliated with or endorsed by Inquirer.js.

About

Inquirer.js wrapper for `npx` usage.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors