clefairy
CLI creation helper
- Parses and validates argv according to your specification (and gives you TypeScript types)
- Calls your function, and, if an error occurs (via sync throw or Promise rejection):
- Pretty-prints the error
- Exits the process with status code 1
Usage Example
import { run, optionalBoolean, requiredString, optionalString } from "clefairy";
run(
{
someColor: optionalString,
someName: requiredString,
v: optionalBoolean,
},
async (options, ...args) => {
console.log({ options, args });
},
{
argv: ["-v", "--some-name", "Jeff", "one", "two", "--", "--hi"],
}
);
License
MIT