fromCommand static method

DartDeclaration fromCommand(
  1. List<Command> commandList,
  2. dynamic self, {
  3. dynamic testSubject,
  4. required String key,
  5. dynamic value,
})

Implementation

static DartDeclaration fromCommand(List<Command> commandList, self,
    {dynamic testSubject, required String key, dynamic value}) {
  var newSelf = self;
  for (var command in commandList) {
    if (testSubject is String) {
      if ((command.prefix != null &&
          testSubject.startsWith(command.prefix!))) {
        if ((command.prefix != null &&
                command.command != null &&
                testSubject.startsWith(command.prefix! + command.command!)) ||
            (command.command != null &&
                testSubject.startsWith(command.command!))) {
          if (command.notprefix != null &&
                  !testSubject.startsWith(command.notprefix!) ||
              command.notprefix == null) {
            newSelf =
                command.callback!(self, testSubject, key: key, value: value);
            break;
          }
        }
      }
    }
    if (testSubject.runtimeType == command.type) {
      newSelf = command.callback!(self, testSubject, key: key, value: value);
      break;
    }
  }
  return newSelf;
}