fromArgs static method

(OutputMode?, String?) fromArgs(
  1. List<String> args
)

Reads the value of the --bp-output flag. The mode is null when the flag is not given

Implementation

static (OutputMode?, String?) fromArgs(List<String> args) {
  for (String arg in args) {
    if (arg == flag) {
      return (null, "$flag needs a value, e.g. $flag=plain. The valid values are: $names");
    }
    if (arg.startsWith("$flag=")) {
      (OutputMode?, String?) parsed = parse(arg.substring(flag.length + 1));
      return parsed.$2 == null ? parsed : (null, "Invalid $flag -> ${parsed.$2}");
    }
  }
  return (null, null);
}