Skip to content

Quick Start

Terminal window
npm install @arshad-shah/clif
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();
Terminal window
# Default greeting
npx tsx greet.ts
# ╭ Greeting ──────────╮
# │ Hello, World! │
# ╰────────────────────╯
# Custom name
npx tsx greet.ts --name Alice
# Loud mode
npx tsx greet.ts -n Alice --loud
# Built-in help
npx tsx greet.ts --help

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?" });
  • Colors — full color API reference
  • Arguments — flags, types, choices, and aliases
  • Commands — nested subcommands and setup hooks
  • Components — box, table, list, tree, spinner, progress