This project was created using bun create mcmd-app in Bun. Bun is a fast all-in-one JavaScript runtime.
Warning
MCMD plugin isn't available on node.js right now. Make sure to use Bun.
bun installTranspile the code (dev mode)
bun --bun run transpile
# or
# bunx --bun mcmd transpileRun the CLI (dev mode)
bun run cli --name Rajat
# or
# bun run ./.mcmd/cli.tsBuild the CLI
bun --bun run build
# or
# bunx --bun mcmd buildroot
├── .mcmd
├── node_modules
│
├─┬ app
│ ├── index.ts # npx my-cli
│ ├─┬ init
│ │ ├── something.ts # npx my-cli init something
│ │ └── index.ts # npx my-cli init
│ └── login.ts # npx my-cli login
│
├── package.json
├── build.ts
├── .gitignore
├── README.md
└── tsconfig.json
Don't need to import zod or Command, we'll handle everything for you.
// app/index.ts
export const options = z.object({
name: z.string()
});
export default Command((data) => {
const { name } = data;
console.log("Hi", name);
});
// npx my-cli --name Rajat// app/init.ts
export default () => {
console.log("Done Init");
};
// npx my-cli initImportant
Make sure to use Bun for building the CLI.
bun --bun run build
# or
# bunx --bun mcmd build// package.json
{
"name": "my-cli",
"version": "0.0.0",
"bin": "./dist/cli.js",
"files": ["dist/**/*"],
...
}bun publishTip
Now you don't strictly need bun to run your CLI.
bunx my-cli --name Rajat