Skip to content

code4fukui/minimist

 
 

Repository files navigation

minimist

日本語のREADMEはこちらです: README.ja.md

A minimalist argument parser.

Features

  • Parses argument options
  • Supports boolean, string, and numeric options
  • Supports aliases for options
  • Handles options with and without equal signs
  • Stops parsing after -- option

Usage

import parse from "https://code4fukui.github.io/minimist/index.js";

const argv = parse(Deno.args);
console.log(argv);
$ deno run example/parse.js -a beep -b boop
{ _: [], a: "beep", b: "boop" }
$ deno run example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
{
  _: [ "foo", "bar", "baz" ],
  x: 3,
  y: 4,
  n: 5,
  a: true,
  b: true,
  c: true,
  beep: "boop"
}

Methods

import parseArgs from "https://code4fukui.github.io/minimist/index.js";

var argv = parseArgs(args, opts={})

Return an argument object argv populated with the array arguments from args.

Options can include:

  • opts.string - arguments to always treat as strings
  • opts.boolean - arguments to always treat as booleans
  • opts.alias - object mapping argument names to aliases
  • opts.default - default values for arguments
  • opts.stopEarly - stop parsing on the first non-option
  • opts['--'] - treat everything after -- as positional arguments

License

MIT License — see LICENSE.

About

parse argument options

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%