flags

Command line arguments parser for Deno based on minimist

Example

const { args } = Deno;
import { parse } from "https://deno.land/std/flags/mod.ts";

console.dir(parse(args));
$ deno example.ts -a beep -b boop
{ _: [], a: 'beep', b: 'boop' }
$ deno example.ts -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' }

API

const parsedArgs = parse(args, options = {});

parsedArgs._ contains all the arguments that didn't have an option associated with them.

Numeric-looking arguments will be returned as numbers unless options.string or options.boolean is set for that argument name.

Any arguments after '--' will not be parsed and will end up in parsedArgs._.

options can be:

  const { args } = Deno;
  import { parse } from "https://deno.land/std/flags/mod.ts";
  // options['--'] is now set to false
  console.dir(parse(args, { "--": false }));
  // $ deno example.ts -- a arg1
  // output: { _: [ "example.ts", "a", "arg1" ] }
  // options['--'] is now set to true
  console.dir(parse(args, { "--": true }));
  // $ deno example.ts -- a arg1
  // output: { _: [ "example.ts" ], --: [ "a", "arg1" ] }

View repository on GitHub