| 116 | }) |
| 117 | |
| 118 | function formatSessionTable(sessions: Session.Info[]): string { |
| 119 | const lines: string[] = [] |
| 120 | |
| 121 | const maxIdWidth = Math.max(20, ...sessions.map((s) => s.id.length)) |
| 122 | const maxTitleWidth = Math.max(25, ...sessions.map((s) => s.title.length)) |
| 123 | |
| 124 | const header = `Session ID${" ".repeat(maxIdWidth - 10)} Title${" ".repeat(maxTitleWidth - 5)} Updated` |
| 125 | lines.push(header) |
| 126 | lines.push("─".repeat(header.length)) |
| 127 | for (const session of sessions) { |
| 128 | const truncatedTitle = Locale.truncate(session.title, maxTitleWidth) |
| 129 | const timeStr = Locale.todayTimeOrDateTime(session.time.updated) |
| 130 | const line = `${session.id.padEnd(maxIdWidth)} ${truncatedTitle.padEnd(maxTitleWidth)} ${timeStr}` |
| 131 | lines.push(line) |
| 132 | } |
| 133 | |
| 134 | return lines.join(EOL) |
| 135 | } |
| 136 | |
| 137 | function formatSessionJSON(sessions: Session.Info[]): string { |
| 138 | const jsonData = sessions.map((session) => ({ |