showHelp function

void showHelp()

Implementation

void showHelp() {
  final options = [
    ('help, --help, -h', 'Display this help message'),
    ('version, --version, -v', 'Show the current version of commands'),
    ('clean, --clean, -c', 'Remove all generated commands'),
    ('create [--empty|-e]', 'Create a new commands.yaml file (use --empty or -e for empty file)'),
    ('deactivate, --deactivate, -d [command]', 'Deactivate commands package or specific commands'),
    ('list, --list, -l', 'List all installed commands'),
    ('regenerate, --regenerate, -r', 'Clean and regenerate all previously generated commands'),
    ('update, --update, -u', 'Update commands package to the latest version'),
    ('watch, --watch, -w', 'Watch commands.yaml for changes and auto-reload'),
    ('--watch-detached, -wd', 'Start watching in detached mode (background process)'),
    ('--watch-kill, -wk', 'Kill the detached watcher process'),
    ('--watch-kill-all, -wka', 'Kill all detached watcher processes'),
    ('--exit-error, -ee', 'Exit with code 1 immediately on error'),
    ('--exit-warning, -ew', 'Exit with code 1 immediately on error or warning'),
    ('--silent, -s', 'Suppress all output (combine with exit options to show only errors/warnings)'),
  ];

  final maxLength = options.map((o) => o.$1.length).reduce((a, b) => a > b ? a : b);

  print('''
${bold}Commands - CLI tool for managing custom commands$reset

${bold}Usage:$reset commands [option]

${bold}Options:$reset''');

  for (final (option, description) in options) {
    final padding = ' ' * (maxLength - option.length);
    print('  $blue$option$reset$padding  $gray- $description$reset');
  }

  print('''

${bold}Default behavior:$reset
  Running ${blue}commands$reset without arguments will load and activate
  all commands from commands.yaml in the current directory

${bold}Examples:$reset
  ${blue}commands --silent$reset            $gray- Activate commands without any output$reset
  ${blue}commands -s -ee$reset              $gray- Silent mode, exit on error (shows only errors)$reset
  ${blue}commands --exit-warning$reset      $gray- Exit with error code if warnings occur$reset''');
}