retrieveLabels method

Iterable<String?> retrieveLabels(
  1. PendingTask pending, {
  2. required String? loading,
  3. required String spacing,
})

Implementation

Iterable<String?> retrieveLabels(
  PendingTask pending, {
  required String? loading,
  required String spacing,
}) sync* {
  final task = pending.resolvedTask;

  final iconString = icon(pending, loading: loading);
  final fileCountString = fileCount(task.fileCount);
  final indexString = getIndexString(task.index);

  final status = this.status(pending);
  yield trim(
    '$indexString$status$spacing$iconString ${task.name} $fileCountString',
  );

  if (pending.files.isEmpty) {
    return;
  }

  if (pending.isHalted) {
    if (!debug) {
      return;
    }
  }

  if (pending.hasCompleted && !pending.isError) {
    return;
  }

  for (final subPending in pending.subTasks) {
    final subTask = subPending.resolvedTask;

    final iconString = icon(subPending, loading: loading);

    final scriptString = switch (subTask) {
      final e when subPending.isError => red.wrap(e.name),
      final e => e.name,
    };

    final indexString = getIndexString(subTask.index);
    final fileCountString = switch (subTask.fileCount == subTask.fileCount) {
      true => '',
      _ => fileCount(subTask.fileCount),
    };
    final status = this.status(subPending);
    yield trim(
      '$indexString$status$spacing$spacer$iconString '
      '$scriptString $fileCountString',
    );

    if (subPending.hasCompleted && !subPending.isError) {
      continue;
    }

    for (final subParent in subPending.subTasks) {
      yield* retrieveLabels(
        subParent,
        loading: loading,
        spacing: '$spacing$spacer$spacer',
      );
    }
  }
}