truncateOutput function
Truncate command output if too long.
Implementation
String truncateOutput(String output, {int maxLength = maxOutputLength}) {
if (output.length <= maxLength) return output;
final truncated = output.substring(0, maxLength);
final remainingLines = output.substring(maxLength).split('\n').length;
return '$truncated\n\n... [$remainingLines lines truncated] ...';
}