Clerc is a full-featured library (tool set) for building CLI Apps in Node.js, Deno or Bun.
Note
This package is ESM-only.
- Lightweight - Dependencies are bundled and minified
- Plugin system - Add rich features on demand.
- Chainable APIs - Composable.
- Developer friendly - Strongly typed, converts flags and parameters to camelCase.
- Parses parameters - No need to read them by yourself.
- I18N - Easy to change different locales.
Install clerc, and create a file named cli.mjs
:
import { Clerc } from "clerc";
Clerc.create(
"foo", // CLI Name
"A foo CLI", // CLI Description
"0.0.0", // CLI Version
)
.command(
"bar", // Command name
"A bar command", // Command description
)
.on(
"bar",
(
_ctx, // The command context, but we haven't used it yet
) => {
console.log("Hello, world from Clerc.js!");
},
)
.parse(); // Parse the arguments and run!
Then run: node cli.mjs bar
. It should log in your shell: Hello, world from Clerc.js!
Please see https://clerc.js.org.
Check the examples made with Clerc.js
:
Clerc uses type-flag
to parse arguments. It is strongly-typed, which brings you better DX. It is powerful(supports custom type) and quite small!
And clerc uses lite-emit
to emit events. It is a event emitter library but with better type support.
The whole bundled and minified @clerc/core
package is only 10KB (ignored types), which is much smaller than yargs, commander, CAC and oclif :)
Hiroki Osame's cleye
is an awesome tool for building CLI apps. Its name sounds quite nice, so I also found an English name Clerc
for this package =)