Quick Start
Installation
Section titled “Installation”npm install @arshad-shah/clifYour first CLI
Section titled “Your first CLI”import { createCLI, green, bold, box } from "@arshad-shah/clif";
const cli = createCLI({ name: "greet", version: "1.0.0", description: "A friendly greeter", args: { name: { type: "string", alias: "n", description: "Who to greet", default: "World", }, loud: { type: "boolean", alias: "l", description: "Shout the greeting", }, }, handler: (ctx) => { // ctx.args.flags is typed; values come straight from your `args` schema. const name = ctx.args.flags.name; let greeting = `Hello, ${green(String(name))}!`; if (ctx.args.flags.loud) greeting = bold(greeting.toUpperCase());
console.log(box(greeting, { title: "Greeting", border: "round" })); },});
cli.run();Run it
Section titled “Run it”# Default greetingnpx tsx greet.ts# ╭ Greeting ──────────╮# │ Hello, World! │# ╰────────────────────╯
# Custom namenpx tsx greet.ts --name Alice
# Loud modenpx tsx greet.ts -n Alice --loud
# Built-in helpnpx tsx greet.ts --helpInteractive prompts
Section titled “Interactive prompts”Prompts live in a separate entry point to keep the core bundle tiny:
import { text, select, confirm } from "@arshad-shah/clif/prompts";
const name = await text({ message: "Project name?" });
const template = await select({ message: "Pick a template", options: [ { label: "Minimal", value: "minimal" }, { label: "Full", value: "full", hint: "recommended" }, ],});
const install = await confirm({ message: "Install dependencies?" });What’s next?
Section titled “What’s next?”- Colors — full color API reference
- Arguments — flags, types, choices, and aliases
- Commands — nested subcommands and setup hooks
- Components — box, table, list, tree, spinner, progress