listOut method

String listOut({
  1. StringBuffer? buffer,
  2. String? prefix,
  3. String wrapCallableKey(
    1. String
    )?,
  4. String wrapNonCallableKey(
    1. String
    )?,
  5. String wrapMeta(
    1. String
    )?,
})

Implementation

String listOut({
  StringBuffer? buffer,
  String? prefix,
  String Function(String)? wrapCallableKey,
  String Function(String)? wrapNonCallableKey,
  String Function(String)? wrapMeta,
}) {
  buffer ??= StringBuffer();

  if (name.startsWith('_')) return buffer.toString();

  wrapCallableKey ??= (key) => key;
  wrapNonCallableKey ??= (key) => key;
  wrapMeta ??= (meta) => meta;
  prefix ??= '';

  if (description != null) {
    buffer.writeln('$prefix${wrapMeta(Keys.description)}: $description');
  }

  if (aliases.isNotEmpty) {
    buffer.writeln('$prefix${wrapMeta(Keys.aliases)}: ${aliases.join(', ')}');
  }

  scripts?.listOut(
    buffer: buffer,
    prefix: '$prefix  ',
    wrapCallableKey: wrapCallableKey,
    wrapNonCallableKey: wrapNonCallableKey,
    wrapMeta: wrapMeta,
  );

  return buffer.toString();
}