minimist 0.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 50

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.

Changelog #

[0.2.0] - 2020-05-01 #

Added #

  • Parsing using MinimistOptions implemented

[0.1.1] - 2020-05-01 #

Changed #

  • lib/src/minimist_base.dart & lib/src/models/minimist_options.dart files formatted with dartfmt command

[0.1.0] - 2020-05-01 #

Added #

  • Simple argument parsing implemented without the parsing options.

example/minimist.dart

import 'package:minimist/minimist.dart';

void main(List<String> arguments) {
  var minimist = Minimist(arguments);
  print(minimist.args);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  minimist: ^0.2.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:minimist/minimist.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Jul 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
Dev dependencies
pedantic ^1.8.0
test ^1.6.0