Skip to content

Commit 2b5736c

Browse files
committed
gh gist --id
1 parent 69d47ca commit 2b5736c

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

main.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ const gistCmd = new Command()
250250
.option("-a, --all", "Include all messages")
251251
.option("-n, --limit <n:integer>", "Number of messages (default 1)", { default: 1 })
252252
.option("-p, --pick <spec:string>", "Pick specific messages (e.g., '1,3-4,7')")
253+
.option("--id <id:string>", "Replace contents of an existing gist by ID")
253254
.action(async (opts) => {
254255
const history = History.read()
255256
await genMissingSummaries(history)
@@ -261,8 +262,6 @@ const gistCmd = new Command()
261262
"Creating a gist requires the `gh` CLI (https://cli.github.com/)",
262263
)
263264
}
264-
const title = opts.title || lastChat.summary
265-
const filename = title ? `LLM chat - ${title}.md` : "LLM chat.md"
266265

267266
let md: string
268267
if (opts.pick) {
@@ -272,7 +271,14 @@ const gistCmd = new Command()
272271
const n = opts.all ? lastChat.messages.length : opts.limit
273272
md = chatToMd({ chat: lastChat, lastN: n, mode: "gist" })
274273
}
275-
await $`gh gist create -f ${filename} --web`.stdinText(md)
274+
275+
if (opts.id) {
276+
await $`gh gist edit ${opts.id} -`.stdinText(md)
277+
} else {
278+
const title = opts.title || lastChat.summary
279+
const filename = title ? `LLM chat - ${title}.md` : "LLM chat.md"
280+
await $`gh gist create -f ${filename} --web`.stdinText(md)
281+
}
276282
})
277283

278284
function modelInfoMd(modelArg: string) {

0 commit comments

Comments
 (0)