import type { Command } from "@cliffy/command"; import { dedent } from "@std/text/unstable-dedent"; import { commit, creationDateFor, modificationDateFor, syncNotebook, } from "../git.ts"; import { print } from "../utils.ts"; import { Hsh } from "../hsh.ts"; import { Notebook } from "../notebook.ts"; function register( cmd: Command, hsh: Hsh, ) { cmd .command("info", "grab information about a note") .arguments("") .action(async (_opts, path) => { const p = await hsh.resolve(path); const root = p.notebook.root; const creationDate = await creationDateFor(root, p.toString()); const modificationDate = await modificationDateFor(root, p.toString()); print(dedent(` File : ${p.entry} Created : ${creationDate.toLocaleString()} Modified: ${modificationDate.toLocaleString()} `)); }); hsh.addHandler({ handleNotebookChanged: async (notebook: Notebook, message: string) => { await commit(notebook, message); await syncNotebook(notebook); }, }); } export default { register };