generatePlainToolHelp function

String generatePlainToolHelp(
  1. ToolDefinition tool
)

Generate plain-text tool help (no ANSI colors).

This provides a simpler alternative to HelpGenerator.generateToolHelp without markdown styling.

Implementation

String generatePlainToolHelp(ToolDefinition tool) {
  final buf = StringBuffer();

  buf.writeln('${tool.name} v${tool.version} - ${tool.description}');
  buf.writeln();
  buf.writeln('Usage: ${tool.name} [options] <pipeline|:command> [args...]');
  buf.writeln();

  // Commands by category
  final buildCmds = <CommandDefinition>[];
  final gitCmds = <CommandDefinition>[];
  final otherCmds = <CommandDefinition>[];

  for (final cmd in tool.visibleCommands) {
    if (cmd.name.startsWith('git')) {
      gitCmds.add(cmd);
    } else if ([
      'versioner',
      'bumpversion',
      'compiler',
      'runner',
      'cleanup',
      'dependencies',
      'publisher',
      'buildsorter',
      'pubget',
      'pubgetall',
      'pubupdate',
      'pubupdateall',
    ].contains(cmd.name)) {
      buildCmds.add(cmd);
    } else {
      otherCmds.add(cmd);
    }
  }

  if (buildCmds.isNotEmpty) {
    buf.writeln('Build Commands:');
    for (final cmd in buildCmds) {
      buf.writeln('  :${cmd.name.padRight(16)} ${cmd.description}');
    }
    buf.writeln();
  }

  if (gitCmds.isNotEmpty) {
    buf.writeln('Git Commands:');
    for (final cmd in gitCmds) {
      buf.writeln('  :${cmd.name.padRight(16)} ${cmd.description}');
    }
    buf.writeln();
  }

  if (otherCmds.isNotEmpty) {
    buf.writeln('Other Commands:');
    for (final cmd in otherCmds) {
      buf.writeln('  :${cmd.name.padRight(16)} ${cmd.description}');
    }
    buf.writeln();
  }

  // Help footer hint
  buf.writeln(
    'Use "${tool.name} help :command" for detailed help on a specific command.',
  );
  buf.writeln();

  // Help topics
  if (tool.helpTopics.isNotEmpty) {
    buf.writeln('Help Topics:');
    for (final topic in tool.helpTopics) {
      buf.writeln('  ${topic.name.padRight(20)} ${topic.summary}');
    }
    buf.writeln();
    buf.writeln('Use "${tool.name} help <topic>" for detailed information.');
    buf.writeln();
  }

  // Footer from tool definition
  if (tool.helpFooter != null) {
    buf.writeln(tool.helpFooter!);
  }

  return buf.toString();
}