The Minimum Viable CLI — Build Your Own Bun-Powered CLI
04 / The code

Here's the whole thing.

ts
import { $ } from 'bun';
import { input, confirm } from '@inquirer/prompts';

const name = await input({ message: 'Project name?' });
const useGit = await confirm({ message: 'Initialize git?' });

await $`mkdir -p ${name}`;
await $`cd ${name} && bun init -y`;
if (useGit) await $`cd ${name} && git init`;

console.log(`Ready: ${name}`);
One file. No build step. Top-level await just works. Run it with bun run cli.ts.
Back to portfolio05 / 09