find method

Script? find(
  1. List<String> keys
)

Implementation

Script? find(List<String> keys) {
  Script? find(String key) {
    if (scripts.containsKey(key)) {
      return scripts[key];
    }

    if (!_hasSetupAliases) {
      _mapAliases();
    }

    if (_aliases.containsKey(key)) {
      return _aliases[key];
    }

    if (_deactivatedAliases.containsKey(key)) {
      Logger.err(
        'The alias "$key" is deactivated '
        'because duplicates have been found in:'
        '\n${_deactivatedAliases[key]!.map((e) => e).join('\n')}',
      );

      return null;
    }
    return null;
  }

  var script = find(keys.first);
  if (script == null) return null;

  for (var i = 1; i < keys.length; i++) {
    final remainingKeys = keys.sublist(i);
    final found = script?.scripts?.find(remainingKeys);
    if (found == null) break;

    script = found;
  }

  if (script?.name != keys.last &&
      script?.aliases.contains(keys.last) != true) {
    return null;
  }

  return script;
}