handle method

  1. @override
Future<void> handle(
  1. List<String> arguments
)
override

Implementation

@override
Future<void> handle (List<String> arguments) async {
  ArgResults results = manager.parser.parse(arguments);
  final command = manager.commands[results.command?.name ?? 'help'];

  if (command != null) {
    if (command.arguments.isNotEmpty && results.arguments.length - 1 != command.arguments.length) {
      command.console.error('Please provide ${command.arguments.map((e) => '<$e>').join(', ')} params.');
      return;
    }

    final params = {};
    for (int i = 0; i < command.arguments.length; i++) {
      params.putIfAbsent(command.arguments[i], () => results.arguments[i + 1]);
    }

    return await command.handle(params);
  }
}