Skip to content

Commit 8f4d706

Browse files
committed
feat(cli): add command docs and simplify session list
1 parent 929374c commit 8f4d706

8 files changed

Lines changed: 640 additions & 177 deletions

File tree

packages/cli/src/commands/handlers/session/list.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const handler = Effect.fn("cli.session.list")(function* (
4747
null,
4848
2,
4949
)
50-
: formatTable(page.data)) + EOL
50+
: formatList(page.data)) + EOL
5151
const write = Effect.tryPromise(
5252
() =>
5353
new Promise<void>((resolve, reject) => {
@@ -96,18 +96,14 @@ export default Runtime.handler(Commands.commands.session.commands.list, (input)
9696
),
9797
)
9898

99-
function formatTable(sessions: ReadonlyArray<SessionInfo>) {
100-
const rows = sessions.map((session) => ({
101-
id: session.id,
102-
title: (session.title ?? "Untitled session").replace(/[\r\n\t]/g, " "),
103-
updated: new Date(session.time.updated).toLocaleString(),
104-
}))
105-
const idWidth = Math.max(20, ...rows.map((row) => row.id.length))
106-
const titleWidth = Math.max(25, ...rows.map((row) => row.title.length))
107-
const header = `${"Session ID".padEnd(idWidth)} ${"Title".padEnd(titleWidth)} Updated`
108-
return [
109-
header,
110-
"─".repeat(header.length),
111-
...rows.map((row) => `${row.id.padEnd(idWidth)} ${row.title.padEnd(titleWidth)} ${row.updated}`),
112-
].join(EOL)
99+
function formatList(sessions: ReadonlyArray<SessionInfo>) {
100+
return sessions
101+
.map((session) =>
102+
[
103+
session.id,
104+
(session.title ?? "Untitled session").replace(/[\r\n\t]/g, " "),
105+
new Date(session.time.updated).toLocaleString(),
106+
].join("\t"),
107+
)
108+
.join(EOL)
113109
}

0 commit comments

Comments
 (0)