minimist 0.3.0 copy "minimist: ^0.3.0" to clipboard
minimist: ^0.3.0 copied to clipboard

A Dart library for parsing command ling options and arguments inspired from minimist npm package.wh

minimist #

Clique-Paris

A Dart module for parsing command line parameters and options, inspired from the minimist npm module.

Usage #

A simple usage example:

import 'package:minimist/minimist.dart';

main(List<String> arguments) {
  var args = Minimist(arguments).args;
  print(args);
}
$ dart example/minimist.dart -f foo -b bar
{_: [], f: foo, b: bar}

$ dart example/minimist.dart -x 0 -y 1 -n2 -abc --hello=world foo bar baz -def42
{_: [foo, bar, baz], x: 0, y: 1, n: 2, a: true, b: true, c: true, hello: world, d: true, e: true, f: 42}

A more complex usage by using parsing options (aka MinimistOptions):

import 'package:minimist/minimist.dart';

main (List<String> arguments) {
  var args = Minimist(arguments,
        options: MinimistOptions(
          string: ['lang', 'username', 'password'],
          boolean: ['pager'],
          alias: <String, String>{
            'h': 'help',
            'v': 'version',
            'u': 'username',
            'password': 'p',
            'g': 'pager'
          },
          byDefault: {'lang': 'en'},
        )).args;
  print(args);
}
$ dart example/minimist_with_options.dart --lang xml --pager -u=root -h hello -- index.js package.json

{_: [index.js, package.json, hello], lang: xml, username: root, u: root, pager: true, g: true, h: true, help: true, v: false, version: false}
$ dart example/minimist_with_options.dart  -- index.js package.json

{_: [index.js, package.json], pager: false, g: false, h: false, help: false, v: false, version: false, lang: en}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0
likes
140
pub points
0%
popularity

Publisher

verified publishermakepad.fr

A Dart library for parsing command ling options and arguments inspired from minimist npm package.wh

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on minimist