npm.io
1.7.0 • Published 7 years ago

@unsc/parse

Licence
MIT
Version
1.7.0
Deps
0
Size
8 kB
Vulns
0
Weekly
0
DeprecatedThis package is deprecated

parse

install

npm install --save @unsc/parse

usage

import parse from "@unsc/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.

Keywords