Use when building CLI commands or tools with Stacks — the @stacksjs/cli package for creating commands with argument parsing, option handling, colored output, tables, progress indicators, prompts, or integrating with the buddy command system. Covers @stacksjs/cli and app/Commands/.
The @stacksjs/cli package provides the foundation for building CLI commands, used internally by the buddy CLI.
storage/framework/core/cli/src/config/cli.tsapp/Commands/app/Commands.ts// app/Commands/Greet.ts
export default {
name: 'greet',
description: 'Greet a user',
alias: 'g',
options: {
name: { alias: 'n', description: 'Name to greet', default: 'World' },
loud: { alias: 'l', description: 'Shout the greeting', type: 'boolean' }
},
handle: async ({ options }) => {
const greeting = `Hello, ${options.name}!`
console.log(options.loud ? greeting.toUpperCase() : greeting)
}
}
export default {
'greet': 'Greet',
'inspire': 'Inspire',
}
app/Listeners/Console.ts// app/Listeners/Console.ts
export default function(cli: CLI) {
cli.on('custom:command', () => {
console.log('Custom command executed!')
})
cli.on('my:*', () => {
// Wildcard — matches my:anything
})
cli.on('unknown:!', () => {
// Default/fallback handler
})
}
Via @stacksjs/utils color functions (available in CLI context):
import { bold, green, red, yellow, dim, underline } from '@stacksjs/utils'
console.log(green('✓ Success'))
console.log(red('✗ Error'))
console.log(yellow('⚠ Warning'))
console.log(bold('Important'))
console.log(dim('Subtle info'))
{
name: 'My Custom CLI',
command: 'mycli',
description: 'My custom CLI tool',
deploy: true
}
buddy make:command [name] — scaffold a new commandbuddy build:cli # build CLI binary
# Compiles for: linux-x64, linux-arm64, windows-x64, darwin-x64, darwin-arm64
app/Commands/, framework commands in storage/framework/core/buddy/src/commands/app/Commands.ts registry*) and default handlers (!)@stacksjs/utils