Skip to main content
Deno 2 is finally here πŸŽ‰οΈ
Learn more

Command Line Parser (Deno Edition)

CommandLineParser.Deno - A Deno 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)

πŸ“ Description

🌟 Feature

  • Easier to remember which is flag and which is option (i.e.: key-value pair).
  • Native support for TypeScript.

πŸ“š Documentation

Getting Started

Deno (>= v1.11.0):

import commandLineParser from "https://deno.land/x/hugoalh_command_line_parser@<Tag/Version>"

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

import commandLineParser from "https://deno.land/x/hugoalh_command_line_parser@0.1.0"

console.log(commandLineParser(["-test", "--message=\"Hello, world!\"", "lol", "---fail"]));
/*
{
  action: [
    "lol"
  ],
  fault: [
    "---fail"
  ],
  flag: [
    "test"
  ],
  option: {
    message: "Hello, world!"
  }
}
*/