EasyCLI

Build beautiful CLIs with TypeScript


Project maintained by ashavijit Hosted on GitHub Pages — Theme by mattgraham

EasyCLI

The modern CLI framework for TypeScript

A complete replacement for Commander.js + Inquirer with better DX.

npm TypeScript License


Quick Start

npx create-easycli my-cli
cd my-cli
pnpm dev hello World

Why EasyCLI?

Feature Commander.js Inquirer EasyCLI
Type inference Manual Manual Automatic
UI components None Prompts only 15+ components
Error handling Basic None Rich errors with hints
Signal handling Manual Partial Built-in
Scaffolding None None npx create-easycli

Features


Example

import { defineCLI } from "easycli-core";
import { colors, spinner, box } from "easycli-ui";

const cli = defineCLI({
  name: "deploy",
  version: "1.0.0",
  commands: {
    up: {
      description: "Deploy to environment",
      args: { env: ["staging", "production"] },
      flags: {
        force: { type: "boolean", alias: "f" },
        replicas: { type: "number", default: 3 }
      },
      async run({ env, force, replicas }, ctx) {
        if (!force) {
          const proceed = await ctx.ask.confirm(`Deploy to ${env}?`);
          if (!proceed) return;
        }

        const s = spinner(`Deploying to ${env}...`);
        s.start();
        await deploy(env, replicas);
        s.success("Deployed!");

        console.log(box([
          `Environment: ${colors.cyan(env)}`,
          `Replicas: ${replicas}`
        ], { borderStyle: "rounded" }));
      }
    }
  }
});

cli.run();

Packages

Package Description
easycli-core CLI definition, parsing, routing
easycli-ui Colors, spinners, progress, tables, boxes
easycli-prompts Interactive prompts, sanitization
easycli-help Help text generation
easycli-config Config file loading
easycli-plugins Plugin system
create-easycli Project scaffolder

Documentation


Example Output

$ my-cli deploy up production --replicas 5

╭──────────────────────────╮
│ Deploying to production  │
╰──────────────────────────╯

? Deploy to production? (y/n) y

⠋ Deploying to production...
✔ Deployed!

╭─────────────────────────╮
│ Environment: production │
│ Replicas: 5             │
╰─────────────────────────╯

License

MIT License - see LICENSE

GitHub | npm