parseAllWithType<T> method

Stream<T?> parseAllWithType<T>()

Finds all the arguments with a type of T in the command callback and parses them.

The values are ordered as they appear in the command callback.

If the user has not yet provided a value, null is added to the stream instead.

You might also be interested in:

Implementation

Stream<T?> parseAllWithType<T>() {
  RuntimeType<T> type = RuntimeType<T>();

  return Stream.fromIterable(
    _functionData.parametersData.where((element) => element.type.isSubtypeOf(type)),
  ).asyncMap(
    (parameter) {
      String? value = arguments[parameter.name];

      if (value == null) {
        return null;
      }

      return converters
          .parse(
            commands,
            this,
            StringView(value, isRestBlock: true),
            parameter.type,
          )
          .then((value) => value as T);
    },
  );
}