@detach/parse

1.9.1 • Public • Published

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.

Package Sidebar

Install

npm i @detach/parse

Weekly Downloads

3

Version

1.9.1

License

MIT

Unpacked Size

8.12 kB

Total Files

10

Last publish

Collaborators

  • npm