| 529 | } |
| 530 | |
| 531 | function renderProjectListText(page: Page<CliProject>): string { |
| 532 | if (page.items.length === 0) { |
| 533 | return page.nextToken |
| 534 | ? `No projects on this page.\nnextToken: ${page.nextToken}` |
| 535 | : 'No projects.'; |
| 536 | } |
| 537 | // Compact, AWS-CLI-grade columnar output. Column widths are computed |
| 538 | // per-call so a single absurdly long project name doesn't push the |
| 539 | // whole table off-screen. |
| 540 | const idWidth = Math.max(2, ...page.items.map(p => p.id.length)); |
| 541 | const nameWidth = Math.max(4, ...page.items.map(p => p.name.length)); |
| 542 | const typeWidth = 8; |
| 543 | const fromWidth = 6; |
| 544 | |
| 545 | const header = |
| 546 | pad('ID', idWidth) + |
| 547 | ' ' + |
| 548 | pad('NAME', nameWidth) + |
| 549 | ' ' + |
| 550 | pad('TYPE', typeWidth) + |
| 551 | ' ' + |
| 552 | pad('FROM', fromWidth) + |
| 553 | ' ' + |
| 554 | 'CREATED'; |
| 555 | |
| 556 | const rows = page.items.map( |
| 557 | p => |
| 558 | pad(p.id, idWidth) + |
| 559 | ' ' + |
| 560 | pad(p.name, nameWidth) + |
| 561 | ' ' + |
| 562 | pad(p.type, typeWidth) + |
| 563 | ' ' + |
| 564 | pad(p.createdFrom, fromWidth) + |
| 565 | ' ' + |
| 566 | p.createdAt, |
| 567 | ); |
| 568 | |
| 569 | const lines = [header, ...rows]; |
| 570 | if (page.nextToken) lines.push('', `nextToken: ${page.nextToken}`); |
| 571 | return lines.join('\n'); |
| 572 | } |
| 573 | |
| 574 | function renderProjectText(p: CliProject): string { |
| 575 | return [ |