printScripts method

void printScripts([
  1. String search = ''
])

Prints the list of scripts in the config.

If search is provided, it filters the scripts to only those that contain the search string.

Implementation

void printScripts([String search = '']) {
  var maxLen = '-h, --help'.length;

  final filtered = search.isEmpty
      ? scripts
      : scripts
          .where((scr) => [scr.name, scr.description]
              .any((s) => s != null && s.contains(search)))
          .toList();

  final mapped = filtered
      .map((scr) => TableRow(scr.name,
          scr.description ?? '\$ ${[scr.cmd, ...scr.args].join(' ')}'))
      .toList();

  final padLen = _getPadLen(mapped.map((r) => r.name).toList(), maxLen);

  _printTable(mapped, padLen);
}