@libraz/node-cli
v1.0.0
Published
[](https://github.com/libraz/node-cli/actions) [](https://www.npmjs.com/package/@libraz/node-cli)
Readme
@libraz/node-cli
Zero-dependency, batteries-included CLI framework for Node.js / TypeScript.
Features
- Interactive shell (REPL) with history and tab completion
- Subcommand hierarchy with fluent builder API
- Built-in color, table, progress bar, spinner, prompts, logger
- Command aliases, validation, events, plugins
- Pipe command chaining, mode sub-REPL
- TypeScript-first, ESM-first, zero production dependencies
Quick Start
import { createCLI } from "@libraz/node-cli";
const cli = createCLI({ name: "myapp" });
cli
.command("greet <name>")
.description("Greet someone")
.option("-u, --uppercase", { type: "boolean" })
.action((ctx) => {
const name = ctx.args.name as string;
const msg = ctx.options.uppercase ? name.toUpperCase() : name;
ctx.stdout.write(`Hello, ${msg}!\n`);
});
cli.start();Built-in Utilities
import { color, c, table, progress, prompt, logger } from "@libraz/node-cli";
// Color
console.log(color.bold.green("Success!"));
console.log(c`{red Error}: failed`);
// Table
console.log(table([{ name: "Alice", role: "Admin" }], { border: "rounded" }));
// Progress
const bar = progress.bar({ total: 100, label: "Download" });
const spinner = progress.spinner({ label: "Loading..." });
// Prompt
const name = await prompt.text("Name:");
const ok = await prompt.confirm("Continue?");
// Logger
const log = logger({ prefix: "app", timestamp: true });
log.info("Started");Requirements
- Node.js >= 20
- ESM (
"type": "module"in package.json)
Documentation
Full documentation: https://github.com/libraz/node-cli
License
MIT
