diff --git a/index.ts b/index.ts index 62f9b7a..a7e8b5d 100644 --- a/index.ts +++ b/index.ts @@ -8,6 +8,7 @@ import { getRunningWork, resolveWorkfilePath, } from "./lib/workfile.ts"; +import { openWorkfileForEdit } from "./lib/edit.ts"; const config = await loadConfig(); const WORKFILE_PATH = await resolveWorkfilePath({ @@ -66,6 +67,10 @@ async function run(command: string) { case "status": await summary(WORKFILE_PATH, config.summary); break; + case "edit": + openWorkfileForEdit(WORKFILE_PATH); + await summary(WORKFILE_PATH, config.summary); + break; default: panic(`Unknown command: ${command}`); } diff --git a/lib/edit.ts b/lib/edit.ts new file mode 100644 index 0000000..95e04b9 --- /dev/null +++ b/lib/edit.ts @@ -0,0 +1,7 @@ +import { execSync } from "node:child_process"; + +export function openWorkfileForEdit(path: string): void { + const editor = process.env["EDITOR"] || "vim"; + const command = `${editor} ${path}`; + execSync(command, { stdio: ["ignore", "inherit", "inherit"] }); +}