helpTopic property

HelpTopic get helpTopic

The help topic <tool> help <code>: the summary, the description, where it is listed and the exit code, and every option at length.

Implementation

HelpTopic get helpTopic {
  final b = StringBuffer()
    ..writeln('$label  [$code]')
    ..writeln()
    ..writeln(summary)
    ..writeln()
    ..writeln(description.trimRight())
    ..writeln()
    ..writeln(
      'Listed under "${_section(level)}"; the run ends with exit '
      '$effectiveExitCode or higher (${ReportExitCode.meaning(effectiveExitCode)}).',
    );
  if (options.isNotEmpty) {
    b
      ..writeln()
      ..writeln('Options:');
    for (final o in options) {
      final syntax = o.valueName != null
          ? '${o.flag} <${o.valueName}>'
          : o.repoList
          ? '${o.flag} <repo>[,<repo>...]'
          : o.flag;
      b.writeln('  $syntax');
      for (final line in o.explanation.split('\n')) {
        b.writeln('      $line');
      }
    }
    if (options.any((o) => o.repoList)) {
      b
        ..writeln()
        ..writeln(
          'A repository is named by its last path segment when that is '
          'unique, else by its path from the root; an option acts only on '
          'the repositories it names.',
        );
    }
  }
  return HelpTopic(name: code, summary: summary, content: b.toString());
}