deno/lib/arg
2025-09-26 19:38:24 +02:00
..
flag the biggest refactoring of 2024 2024-04-04 00:42:45 +02:00
flag.ts the biggest refactoring of 2024 2024-04-04 00:42:45 +02:00
input.ts the biggest refactoring of 2024 2024-04-04 00:42:45 +02:00
mod.ts the biggest refactoring of 2024 2024-04-04 00:42:45 +02:00
options.ts the biggest refactoring of 2024 2024-04-04 00:42:45 +02:00
readme.md lowercase readme 2025-09-26 19:38:24 +02:00

-/arg

very simple argument parser

Usage:

import { bool, int, parse_args, str } from "-/arg/mod.ts";

const [args, flags] = parse_args({
  action: {
    type: str,
    short: "a",
  },
  verbose: {
    type: bool,
    short: "v",
    fallback: false,
  },
});

node script.js -a hello --action next meow

{
  flags: { action: [ "next", "hello" ], verbose: [ false ] },
  args: [ "meow" ],
}

returns args and flags. flags are always an array.

if flags are provided more than once, the last ones appear first in the array. the first array item therefore is always the last flag provided. this is useful e.g. when aliasing a script built with -/arg with default flags.