Elegant CLI framework. Inspired by cac. Works with Deno, Node.js and Bun.
- Infinite nesting for commands (aka
git remote add
) - Default command support
- Automatic help/version, including individual commands and programs
- Argument validation
- Auto-complete for options
- Pluggable (color plugin out-of-the-box)
- Middleware API to run before commands
# Bun
bun i spektr
# pnpm
pnpm i spektr
# Deno
echo "export { CLI } from 'https://deno.land/x/spektr/spektr.ts'" >> deps.ts
import { CLI } from 'https://deno.land/x/spektr/spektr.ts'
import { colorPlugin } from 'https://deno.land/x/spektr/spektr/plugins/color.ts'
const cli = new CLI({ name: 'spektr', plugins: [colorPlugin] })
cli.command(
'hello',
(_, args) => {
args.name ? console.log(`Hello ${args.name}!`) : console.log('Hello!')
},
{
options: [
{ name: 'name', description: 'your name', type: 'string', short: ['n'] },
] as const,
},
)
cli.version()
cli.help()
cli.handle(Deno.args)