Typed CLI argv parser and main function wrapper
MIT License
CLI creation helper
import { run, optionalBoolean, requiredString, optionalString } from "clefairy";
run(
{
someColor: optionalString,
someName: requiredString,
v: optionalBoolean,
},
async (options, ...args) => {
console.log({ options, args });
},
{
// If you don't pass anything here, it defaults to process.argv.slice(2)
// But I pass something here for this example to make it clearer how the
// input argv maps to the options in the function.
argv: ["-v", "--some-name", "Jeff", "one", "two", "--", "--hi"],
}
);
// This gets logged:
// {
// options: { v: true, someName: 'Jeff' },
// args: [ 'one', 'two', '--hi' ]
// }
MIT