Getting Started
WARNING
Clerc only supports ESM!
Installation
INFO
The clerc package exports a Cli function, which is equivalent to Clerc.create().use(versionPlugin).use(helpPlugin). This provides a convenient way to create a CLI with both version and help plugins built-in.
If you need more control, you can use Clerc.create() directly and manually add plugins.
Note that the clerc package may be larger in size since it re-exports all official plugins. However, if your bundler supports tree-shaking, this shouldn't be an issue. To reduce bundle size, consider installing only @clerc/core and the plugins you need.
sh
$ npm install clercsh
$ yarn add clercsh
$ pnpm add clercSimplest CLI Example
Install clerc, and create a file named cli.mjs:
ts
import { Cli } from "clerc";
Cli() // Create a new CLI with help and version plugins
.name("foo") // Optional, CLI name, used to generate help text
.scriptName("foo") // CLI script name
.description("A foo CLI") // CLI description
.version("0.0.0") // CLI version
.command(
"bar", // Command name
"A bar command", // Command description
)
.on(
"bar",
(
_ctx, // Command context, but we're not using it yet
) => {
console.log("Hello, world from Clerc.js!");
},
)
.parse(); // Parse arguments and run!Then run: node cli.mjs bar. It should output in your shell: Hello, world from Clerc.js!

