@hugoalh/command-line-parserdeprecated

A module to parse command line with better standard.

Usage no npm install needed!

<script type="module">
  import hugoalhCommandLineParser from 'https://cdn.skypack.dev/@hugoalh/command-line-parser';
</script>

README

Command Line Parser (NodeJS Edition)

CommandLineParser.NodeJS - A NodeJS module to parse command line with better standard.

GitHub Contributors GitHub Issues GitHub Pull Requests GitHub Discussions GitHub Stars GitHub Forks GitHub Languages CodeFactor Grade LGTM Alerts LGTM Grade License

Release Latest Pre
GitHub GitHub Total Downloads GitHub Latest Release Version (GitHub Latest Release Date) GitHub Latest Pre-Release Version (GitHub Latest Pre-Release Date)
NPM NPM Total Downloads NPM Latest Release Version NPM Latest Pre-Release Version

📝 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-parser

API

(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!"
  }
}
*/