printDetails method

String printDetails()

Implementation

String printDetails() {
  if (this.name.startsWith('_')) return '';

  final buffer = StringBuffer();

  final name = cyan.wrap(this.name);

  final keys = yellow.wrap(this.keys.join(' '));
  buffer.writeln('$name: $keys');

  if (description case final String description) {
    final descriptionTitle = darkGray.wrap('description');
    buffer.writeln('  $descriptionTitle: $description');
  }

  if (scripts?.scripts.values case final scripts?) {
    for (final script in scripts) {
      final lines = script.printDetails().split('\n');

      for (final line in lines) {
        final trimmed = line.trimRight();
        if (trimmed.isEmpty) continue;

        buffer.writeln('  $trimmed');
      }
    }
  }

  return buffer.toString();
}