stacksjs/clapp
โ A modern framework to build powerful & pretty CLI applications.
An elegant, TypeScript-first CLI framework built on Bun for creating beautiful command-line applications with interactive prompts.
This toolkit comes packed with everything you need to build professional command-line applications:
Create beautiful, interactive command-line experiences with our pre-styled prompt components:
import { confirm, intro, multiselect, outro, select, spinner, text } from '@stacksjs/clapp'
// Start an interactive session
intro('Project Setup Wizard')
// Simple text input
const name = await text({
message: 'What is your project name?',
placeholder: 'my-awesome-project',
validate(value) {
if (value.length === 0)
return 'Name is required!'
},
})
// Yes/no confirmation
const useTypeScript = await confirm({
message: 'Do you want to use TypeScript?'
})
// Single selection from a list
const framework = await select({
message: 'Select a framework:',
options: [
{ value: 'react', label: 'React' },
{ value: 'vue', label: 'Vue', hint: 'recommended' },
{ value: 'svelte', label: 'Svelte' },
],
})
// Multiple selections
const features = await multiselect({
message: 'Select additional features:',
options: [
{ value: 'router', label: 'Router' },
{ value: 'state', label: 'State Management' },
{ value: 'testing', label: 'Testing' },
],
required: false,
})
// Show a spinner for long-running tasks
const s = spinner()
s.start('Installing dependencies')
// Simulate installation
await new Promise(resolve => setTimeout(resolve, 2000))
s.stop('Installation complete!')
// End the session
outro('You\'re all set! Happy coding!')
Build powerful command-line applications with a simple and elegant API inspired by CAC:
import { CLI } from '@stacksjs/clapp'
const cli = new CLI('todo-app')
.version('1.0.0')
.help()
cli
.command('add <task>', 'Add a new task')
.option('-p, --priority <level>', 'Priority level (high, medium, low)')
.action((task, options) => {
console.log(`Adding task: ${task} with priority: ${options.priority || 'medium'}`)
})
cli
.command('list', 'List all tasks')
.option('-a, --all', 'Show all tasks including completed ones')
.action((options) => {
console.log(`Listing ${options.all ? 'all' : 'pending'} tasks`)
})
cli.parse()
Getting started with clapp is simple:
# Use this GitHub template or run the following command:
bunx degit stacksjs/clapp my-cli-app
cd my-cli-app
# Install dependencies
bun install
# Build the library
bun run build
# After you commit changes, you can create a release
bun run release # automates versioning and changelog generation
Run the test suite with:
bun test
Please see our releases page for more information on what has changed recently.
Please see CONTRIBUTING for details.
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
For casual chit-chat with others using this package:
Join the Stacks Discord Server
"Software that is free, but hopes for a postcard." We love receiving postcards from around the world showing where Stacks is being used! We showcase them on our website too.
Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States ๐
We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.
The MIT License (MIT). Please see LICENSE for more information.
Made with ๐