Skip to content

Repository files navigation

Contributors Forks Stars Issues License

Terminal GUI Prompts

Terminal prompts that promote to native GUI dialogs when a TTY has a desktop; always echo prompt text for pipes/AI.
Explore the docs

Report Bug · Request Feature

About The Project

Enhanced terminal UI that promotes confirmations and text prompts to native Windows dialogs when the process has a TTY and GUI. The prompt text is always written to stdout so that piped output (e.g. to an AI or log) still shows the question—only the input is promoted to a modal when possible.

Part of OpenShellOrg.

CLI tools often ask for y/n or a line of text. In an interactive Windows terminal with a GUI, users can instead get a native dialog with a default (e.g. "Yes") so that pressing Enter confirms without typing.

(back to top)

Installation

pnpm add terminal-gui-prompts

(back to top)

Usage

Confirm (Yes/No)

import { confirm, confirmBoolean } from "terminal-gui-prompts";

const answer = await confirm({
  message: "Delete all files in this folder?",
  title: "Confirm delete",
  default: "yes",
});
if (answer === "y") doDelete();

const ok = await confirmBoolean({ message: "Continue?" });

Text prompt

import { prompt } from "terminal-gui-prompts";

const name = await prompt({
  message: "Enter your name",
  title: "User",
  default: "Guest",
});

Behaviour

  • Always: the message is written to stdout (so pipes and logs see the question).

  • On Windows, with a TTY and no forceTerminal: a native dialog is shown.

  • Otherwise: a normal terminal prompt is used.

Use forceTerminal: true to always use the terminal, e.g. in scripts.

CLI framework adapters

Adapters for @inquirer/prompts and Enquirer are available. See examples and published docs: https://openshellorg.github.io/docs/terminal-gui-prompts/

(back to top)

API

  • confirm(options)Promise<"y" | "n">

  • confirmBoolean(options)Promise<boolean>

  • prompt(options)Promise<string>

  • canUseWindowsGui()boolean

License

MIT — see LICENSE.

(back to top)

About

Terminal prompts that promote to native GUI dialogs when a TTY has a desktop; always echo prompt text for pipes/AI.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages