1.9.1 • Published 5 years ago

@detach/parse v1.9.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

parse

npm.io npm.io npm.io npm.io

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.