| 102 | }) |
| 103 | |
| 104 | function formatSessionTable(sessions: Session.Info[]): string { |
| 105 | const lines: string[] = [] |
| 106 | |
| 107 | const maxIdWidth = Math.max(20, ...sessions.map((s) => s.id.length)) |
| 108 | const maxTitleWidth = Math.max(25, ...sessions.map((s) => s.title.length)) |
| 109 | |
| 110 | const header = `Session ID${" ".repeat(maxIdWidth - 10)} Title${" ".repeat(maxTitleWidth - 5)} Updated` |
| 111 | lines.push(header) |
| 112 | lines.push("─".repeat(header.length)) |
| 113 | for (const session of sessions) { |
| 114 | const truncatedTitle = Locale.truncate(session.title, maxTitleWidth) |
| 115 | const timeStr = Locale.todayTimeOrDateTime(session.time.updated) |
| 116 | const line = `${session.id.padEnd(maxIdWidth)} ${truncatedTitle.padEnd(maxTitleWidth)} ${timeStr}` |
| 117 | lines.push(line) |
| 118 | } |
| 119 | |
| 120 | return lines.join(EOL) |
| 121 | } |
| 122 | |
| 123 | function formatSessionJSON(sessions: Session.Info[]): string { |
| 124 | const jsonData = sessions.map((session) => ({ |