Dart API ReferenceargsArgResults

ArgResults class

The results of parsing a series of command line arguments using ArgParser.parse(). Includes the parsed options and any remaining unparsed command line arguments.

class ArgResults {
  final Map _options;

  /**
   * The remaining command-line arguments that were not parsed as options or
   * flags. If `--` was used to separate the options from the remaining
   * arguments, it will not be included in this list.
   */
  final List<String> rest;

  /** Creates a new [ArgResults]. */
  ArgResults(this._options, this.rest);

  /** Gets the parsed command-line option named [name]. */
  operator [](String name) {
    if (!_options.containsKey(name)) {
      throw new ArgumentError(
          'Could not find an option named "$name".');
    }

    return _options[name];
  }

  /** Get the names of the options as a [Collection]. */
  Collection<String> get options => _options.getKeys();
}

Constructors

new ArgResults(Map _options, List<String> rest) #

Creates a new ArgResults.

ArgResults(this._options, this.rest);

Properties

final Collection<String> options #

Get the names of the options as a Collection.

Collection<String> get options => _options.getKeys();

final List<String> rest #

The remaining command-line arguments that were not parsed as options or flags. If -- was used to separate the options from the remaining arguments, it will not be included in this list.

final List<String> rest;

Operators

operator [](String name) #

Gets the parsed command-line option named name.

operator [](String name) {
  if (!_options.containsKey(name)) {
    throw new ArgumentError(
        'Could not find an option named "$name".');
  }

  return _options[name];
}