← 全部工具

Ismail-elkorchi/terminal-ui

热度 70 更新于 网络与系统管理

Terminal UI primitives for JavaScript CLIs: prompts, shell hosts, widgets, accessibility hooks, and tests.

githubauto-collected

安装

暂未验证可直接使用的安装命令,请查看项目官方文档或 Release。

@ismail-elkorchi/terminal-ui

Build typed prompts and full-screen terminal applications from the same component, layout, input, accessibility, and testing foundations.

terminal-ui is ESM-only, has no runtime dependencies, and supports Node =24, current Deno and Bun, and memory-backed tests.

The 0.1.x line is a development release. Public declarations are marked stable, beta, or experimental in the generated API reference. Terminal graphics remain experimental pending physical-terminal compatibility evidence.

Install

Node:

npm install @ismail-elkorchi/terminal-ui

Bun:

bun add @ismail-elkorchi/terminal-ui

Deno:

deno add jsr:@ismail-elkorchi/terminal-ui

Use the root entrypoint for ordinary applications. Focused entrypoints such as /prompts, /testing, /theme, and /component keep specialized APIs discoverable without requiring private imports.

Run a Prompt

import { input, runPrompt } from '@ismail-elkorchi/terminal-ui/prompts';

const result = await runPrompt(input({
  label: 'Project name',
  required: true
}));

if (result.status === 'submitted') {
  console.log(result.value);
} else {
  console.error(`Prompt ${result.reason}`);
}

Cancellation, validation failure, timeout, non-TTY denial, and host failure are typed results rather than ordinary control-flow exceptions.

Build a TUI

Applications own state. Components render that state and emit typed messages; update() is the only place that changes it.

import {
  button,
  column,
  defineTui,
  runTui,
  text
} from '@ismail-elkorchi/terminal-ui';

interface State {
  readonly count: number;
}