A powerful CLI framework for building command line applications, powered by Funish.
- 🚀 Simple and intuitive API
- 📦 Automatic package.json metadata integration
- 🎯 Type-safe command definitions
- 🔄 Nested subcommands support
- ⚙️ Automatic help generation
- 🎨 Beautiful command-line output
- 💪 Built on top of citty
- 🌟 Full TypeScript support
# npm
$ npm install @funish/cli
# yarn
$ yarn add @funish/cli
# pnpm
$ pnpm add @funish/cliimport { defineCommand } from "@funish/cli";
const cmd = defineCommand({
meta: {
name: "greet",
},
args: {
name: {
type: "string",
description: "Name to greet",
required: true,
},
},
run: (ctx) => {
console.log(`Hello, ${ctx.args.name}!`);
},
});const cmd = defineCommand({
meta: {
name: "app",
},
subCommands: {
serve: {
args: {
port: {
type: "number",
default: 3000,
},
},
run: (ctx) => {
console.log(`Starting server on port ${ctx.args.port}`);
},
},
},
});The defineCommand function automatically reads metadata from your package.json:
const cmd = defineCommand({
// No need to specify name, version, or description
// They are automatically loaded from package.json
args: {
// ...
},
run: (ctx) => {
// ...
},
});Creates a command definition with automatic metadata from package.json.
def(CommandDef): Command definition objectmeta?: Command metadataargs?: Command arguments definitionsubCommands?: Nested subcommandsrun: Command execution function
Returns an enhanced command definition with metadata from package.json.
Reads the nearest package.json file.
path(string, optional): Starting directory path (defaults to current script directory)
Returns the parsed package.json content or an empty object if not found.
Please read our Contributing Guide before submitting a Pull Request to the project.