run method

  1. @override
FutureOr run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
FutureOr run() async {
  _world.argResults = argParser.parse(argResults?.arguments ?? []);
  final rest = argResults?.rest;
  if (rest != null && rest.isNotEmpty) {
    if (rest.length == 1) {
      _world.addObject('rest.single', rest.single);
    } else {
      _world.addObject('rest', rest.join(' '));

      _world.addObject('rest.list', rest);
    }
  }

  final _exe = _world.commands['execute'];

  await _exe?.call(_world, _execute);

  // for (var command in _execute ?? []) {
  //   command as Map;
  //   final key = command.entries.first.key;
  //   final value = command.entries.first.value;
  //
  //   if (_world.commands.containsKey(key)) {
  //     await _world.commands[key]?.call(_world, value);
  //   } else {
  //     _world.addObject(key, value);
  //   }
  // }
}