parseArgs function

Map<String, List<String>> parseArgs(
  1. Iterable<String> args
)

Implementation

Map<String, List<String>> parseArgs(Iterable<String> args) {
  final argsMap = <String, List<String>>{};
  String? currentKey;

  for (final arg in args) {
    if (arg.startsWith('-')) {
      currentKey = arg;
      argsMap[currentKey] = [];
    } else if (currentKey != null) {
      argsMap[currentKey]!.add(arg);
    }
  }

  return argsMap;
}