PackagesCerebroQuick Start

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):

cli.js
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.js

Or if using TypeScript with tsx:

chmod +x cli.ts

Run 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:

cli.ts
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 Alice

Congratulations! You've created your first CLI with Cerebro. Now explore the Commands Guide to learn more about advanced features.

What's Next?

Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues