reduceHandlers method

List<(String, Function)> reduceHandlers()

Implementation

List<(String, Function handler)> reduceHandlers() {
  if (_subCommands.isEmpty && _groups.isEmpty) {
    return [('$_name', _handle!)];
  }

  final List<(String, Function handler)> handlers = [];

  for (final subCommand in _subCommands) {
    handlers.add(('$_name.${subCommand.name}', subCommand.handle!));
  }

  for (final group in _groups) {
    for (final subCommand in group.commands) {
      handlers.add(
          ('$_name.${group.name}.${subCommand.name}', subCommand.handle!));
    }
  }

  return handlers;
}