0.12.1 • Published 4 years ago
@hugoalh/command-line-parser v0.12.1
Command Line Parser (NodeJS Edition)
CommandLineParser.NodeJS - A NodeJS module to parse command line with better standard.
| Release | Latest | Pre |
|---|---|---|
| GitHub | ||
| NPM |
📝 Description
For Deno edition, please visit here.
🌟 Feature
- Easier to remember which is flag and which is option (i.e.: key-value pair).
- Native support for CommonJS and ECMAScript.
📚 Documentation
Getting Started
NodeJS (>= v14.15.0) & NPM (>= v6.14.8):
npm install @hugoalh/command-line-parserAPI
(commandLine?)
Description
Parse command line.
Argument
commandLine?
<string[] = process.argv.slice(2)> Command line that need to parse.
Return
<object> Parse result.
action:<string[]>fault:<string[]>Unparseable argument.flag:<string[]>Flag.option:<object>Key-value pair.
Example
const commandLineParser = require("@hugoalh/command-line-parser");
console.log(commandLineParser(["-test", "--message=\"Hello, world!\"", "lol", "---fail"]));
/*
{
action: [
"lol"
],
fault: [
"---fail"
],
flag: [
"test"
],
option: {
message: "Hello, world!"
}
}
*/