README
Command Line Parser (NodeJS Edition)
A NodeJS module to parse command line with better standard.
License | MIT |
Release (GitHub) |
Latest: () Pre: () |
Release (NPM) |
Latest: Pre: |
Contributor | |
Issue | : |
Pull Request | : |
Code Quality |
📜 Description
🌟 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-parser
API
(commandLine?)
Description
Parse command line.
Argument
commandLine?
<string[] = []>
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!"
}
}
*/