0.1.0 • Published 4 years ago
@hugoalh/cli-argument-parser v0.1.0
[NodeJS] CLI Argument Parser
A NodeJS library/module and CLI to parse CLI argument with hugoalh standard.
📜 Description
🌟 Feature
- Easier to remember which is flag and which is key-value pair.
- Native support for CommonJS and ECMAScript.
📄 Documentation
For the official documentation, please visit GitHub Repository Wiki.
Getting Started (Excerpt)
For Library/Module
NodeJS (>= v10.13) & NPM (>= v6.4.1):
> npm install @hugoalh/cli-argument-parser
For CLI
NodeJS (>= v10.13) & NPM (>= v6.4.1):
# Use either one
> npm install -g @hugoalh/cli-argument-parser
> npm install --global @hugoalh/cli-argument-parser
API (Excerpt)
parse(cliArgument?)
CLI (Excerpt)
...[cli-argument]
Example
const cliArgumentParser = require("@hugoalh/cli-argument-parser");
console.log(cliArgumentParser.parse(["-test", "--message:=\"Hello, world!\"", "lol", "---fail"]));
/*
{
flag: ["test"],
line: ["lol"],
pair: {
message: "Hello, world!"
},
unparseable: ["---fail"]
}
*/
> cli-argument-parser -test --message:="Hello, world!" lol ---fail
{
flag: ["test"],
line: ["lol"],
pair: {
message: "Hello, world!"
},
unparseable: ["---fail"]
}