Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/workerd/cli.ts>parseArgs

A JavaScript extension package for building strong and modern applications.
Latest
function parseArgs
import { parseArgs } from "https://deno.land/x/ayonli_jsext@v0.9.72/workerd/cli.ts";

Parses the given CLI arguments into an object.

Examples

Example 1

import { parseArgs } from "@ayonli/jsext/cli";

const args = parseArgs([
    "Bob",
    "--age", "30",
    "--married",
    "--wife=Alice",
    "--children", "Mia",
    "--children", "Ava",
    "-p"
], {
    alias: { "p": "has-parents" },
    lists: ["children"],
});

console.log(args);
// {
//     "0": "Bob",
//     age: 30,
//     married: true,
//     wife: "Alice",
//     children: ["Mia", "Ava"],
//     "has-parents": true
// }

Parameters

args: string[]
optional
options: ParseOptions = [UNSUPPORTED]

Returns

{ [key: string]:
| string
| number
| boolean
| (string | number | boolean)[]
; [x: number]: string | number | boolean; --?: string[]; }