Quick Start
Get started with Cerebro and build your first CLI in under 2 minutes.
Last updated:
Get started with Cerebro and build your first CLI in under 2 minutes.
Install Cerebro
Install the package using your preferred package manager:
bash pnpm add @visulima/cerebro bash npm install @visulima/cerebro bash yarn add @visulima/cerebro Create Your CLI File
Create a new file cli.js (or cli.ts for TypeScript):
import { Cerebro } from "@visulima/cerebro";
const cli = new Cerebro("my-app", {
packageName: "my-app",
packageVersion: "1.0.0",
});
cli.addCommand({
name: "hello",
description: "Say hello to someone",
argument: {
name: "name",
type: String,
description: "Name to greet",
defaultValue: "World",
},
options: [
{
name: "greeting",
alias: "g",
type: String,
description: "Custom greeting",
defaultValue: "Hello",
},
],
execute: ({ argument, options, logger }) => {
const name = argument?.[0] || "World";
logger.info(`${options.greeting}, ${name}!`);
},
});
await cli.run();Make It Executable
Add the shebang and make it executable:
chmod +x cli.jsOr if using TypeScript with tsx:
chmod +x cli.tsRun Your CLI
Now you can run your CLI:
# Default greeting
node cli.js hello
# Output: Hello, World!
# With a name
node cli.js hello Alice
# Output: Hello, Alice!
# With custom greeting
node cli.js hello Alice --greeting "Hi"
# Output: Hi, Alice!
# Using alias
node cli.js hello Alice -g "Hey"
# Output: Hey, Alice!TypeScript Support
For TypeScript, use the same code but with .ts extension:
import { Cerebro } from "@visulima/cerebro";
// ... same code ...Run with tsx or compile first:
# Using tsx
tsx cli.ts hello Alice
# Or compile and run
tsc cli.ts && node cli.js hello AliceCongratulations! You've created your first CLI with Cerebro. Now explore the Commands Guide to learn more about advanced features.
What's Next?
- Commands Guide - Learn about command configuration
- Options & Arguments - Handle CLI options and arguments
- Plugins - Extend functionality with plugins
- API Reference - Complete API documentation