[READ-ONLY] Mirror of https://github.com/bombshell-dev/args. <1kB CLI flag parser
args args-parser cli command-line command-line-parser node
5

Configure Feed

Select the types of activity you want to include in your feed.

16 3 9

Clone this repository

https://tangled.org/bomb.sh/args https://tangled.org/did:plc:fpp3tb3sxtikwyfxt3pi7gdl
git@tangled.org:bomb.sh/args git@tangled.org:did:plc:fpp3tb3sxtikwyfxt3pi7gdl

For self-hosted knots, clone URLs may differ based on your setup.



README.md

ultraflag#

A 730B library for parsing CLI flags. Inspired by Deno's std flags module.

Features#

  • It's very small.
  • It's very fast.

Usage#

Basic usage does not require any configuration.

import { parse } from "ultraflag";

// my-cli build --bundle -rf --a value --b=value --c 1
const argv = process.argv.slice(2);
const args = parse(argv);

console.log(args);
// { _: ['build'], bundle: true, r: true, f: true, a: "value", b: "value", c: 1 }

Parsing can be configured to ensure values are handled in a certain format.

const args = parse(argv, {
  default: { a: 1, b: 2, c: "value" },
  alias: { h: "help" },
  boolean: ["foo", "bar"],
  string: ["baz", "qux"],
  array: ["input"],
});

Benchmarks#

mri           x 1,285,159 ops/sec ±0.29% (90 runs sampled)
ultraflag     x 986,699 ops/sec ±0.38% (91 runs sampled)
minimist      x 250,866 ops/sec ±0.59% (92 runs sampled)
yargs-parser  x 18,153 ops/sec ±4.30% (85 runs sampled)