@robojs/cli
Build standalone CLI apps with file-based routing powered by Robo.js.
Create professional command-line applications with minimal boilerplate. Define commands as files, and @robojs/cli generates a standalone executable during robo build. Full TypeScript inference, automatic help generation, subcommand nesting, and extensible hooks come out of the box.
Features
File-based Routing
Commands map directly to files in your project
Type-safe Options
Full TypeScript inference for command options
Subcommands
Nested directories become subcommands automatically
Auto Help
Help text generated from your config
Zero Config
Works out of the box with sensible defaults
Installation
Add to your existing Robo.js project:
npx robo add @robojs/cli@nextOr scaffold a new project with the plugin:
npx create-robo@next my-cli -p @robojs/cli@nextQuick start
Create a command
import { createCliCommandConfig, type CliContext } from 'robo.js/cli.js'
export const config = createCliCommandConfig({
description: 'Say hello to someone',
options: [
{ alias: '-n', name: '--name', description: 'Name to greet', type: 'string', default: 'World' }
]
} as const)
export default (ctx: CliContext<typeof config>) => {
console.log(`Hello, ${ctx.options.name}!`)
}export const config = {
description: 'Say hello to someone',
options: [
{ alias: '-n', name: '--name', description: 'Name to greet', type: 'string', default: 'World' }
]
}
export default (ctx) => {
console.log(`Hello, ${ctx.options.name}!`)
}Build and link
npx robo build
npm linkThe bin field is automatically added to package.json during build, and npm link makes your CLI available by name.
Run
my-cli hello
# Hello, World!
my-cli hello --name Robo
# Hello, Robo!During robo dev, you can also use /cli link in the interactive terminal or /cli run to test commands inline. See the Development guide for more.
