fromCommandLine method

bool fromCommandLine (
  1. String line
)

Add space delimited options.

Let process @options directives

Implementation

bool fromCommandLine(String line) {
  Match match;
  final regOption =
      RegExp(r'^--?([a-z][0-9a-z-]*)(?:=(.*))?$', caseSensitive: false);
  var result = true;

  line.split(' ').forEach((String arg) {
    if ((match = regOption.firstMatch(arg)) != null) {
      result = result && parse(match);
    }
  });
  return result;
}