| 204 | } |
| 205 | |
| 206 | function section(heading: string, rows: CommandRow[], width: number): string[] { |
| 207 | const out: string[] = [] |
| 208 | out.push(bold(yellow(heading))) |
| 209 | const descWidth = width - COMMAND_COLUMN_WIDTH - 2 |
| 210 | for (const row of rows) { |
| 211 | const namePainted = magenta(row.name) |
| 212 | const descLines = wrapLines(row.description, descWidth) |
| 213 | out.push(' ' + pad(namePainted, COMMAND_COLUMN_WIDTH) + descLines[0]) |
| 214 | for (const cont of descLines.slice(1)) { |
| 215 | out.push(' ' + ' '.repeat(COMMAND_COLUMN_WIDTH) + cont) |
| 216 | } |
| 217 | if (row.flags) { |
| 218 | const flagLines = wrapLines(row.flags, descWidth) |
| 219 | for (const line of flagLines) { |
| 220 | out.push(' ' + ' '.repeat(COMMAND_COLUMN_WIDTH) + dim(cyan(line))) |
| 221 | } |
| 222 | } |
| 223 | } |
| 224 | return out |
| 225 | } |
| 226 | |
| 227 | function paragraph(lines: string[]): string[] { |
| 228 | return ['', ...lines, ''] |