Repository
Current version released
5 years ago
Versions
parseargs 
Command line arguments parser for Deno based on minimist
Example
import { args } from "deno";
import parseArgs from "https://github.com/bartlomieju/parseargs/index.ts";
console.dir(parseArgs(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 = parseArgs(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:
options.string- a string or array of strings argument names to always treat as stringsoptions.boolean- a boolean, string or array of strings to always treat as booleans. iftruewill treat all double hyphenated arguments without equal signs as boolean (e.g. affects--foo, not-for--foo=bar)options.alias- an object mapping string names to strings or arrays of string argument names to use as aliasesoptions.default- an object mapping string argument names to default valuesoptions.stopEarly- when true, populateparsedArgs._with everything after the first non-optionoptions['--']- when true, populateparsedArgs._with everything before the--andparsedArgs['--']with everything after the--. Here’s an example:options.unknown- a function which is invoked with a command line parameter not defined in theoptionsconfiguration object. If the function returnsfalse, the unknown option is not added toparsedArgs.
Contributing
Feel free to open PRs with suggestions.
License
MIT