@detach/parse
v1.9.1
Published
command line argument parser
Downloads
26
Maintainers
Readme
parse
install
npm install @detach/parse
usage
import parse from "@detach/parse";
const custom = parse("my command here --myOption John -myFlag");
// const custom = parse(process.argv); <- You can do this too!
parsed.getCommand(); // my command here
parsed.getOptions(); // { myOption: "John", myFlag: true }
parsed.getOption("myOption"); // John
parsed.getOption("myFlag"); // true
That's it! 😜 You now have access to the parsed arguments.
extras
You can even listen for commands using .on
.
parse.on("my command here", function(options) {
// the first .on to match gets called, others get ignored
});
contribute
Pull requests are encouraged.