flag method

bool flag(
  1. String name
)

Returns the parsed or default command-line flag named name.

name must be a valid flag name in the parser.

Implementation

bool flag(String name) {
  var option = _parser.options[name];
  if (option == null) {
    throw ArgumentError('Could not find an option named "--$name".');
  }
  if (!option.isFlag) {
    throw ArgumentError('"$name" is not a flag.');
  }
  return option.valueOrDefault(_parsed[name]) as bool;
}