A note-taking app inspired by nb
at main 42 lines 1.1 kB view raw
1import type { Command } from "@cliffy/command"; 2import { dedent } from "@std/text/unstable-dedent"; 3 4import { 5 commit, 6 creationDateFor, 7 modificationDateFor, 8 syncNotebook, 9} from "../git.ts"; 10import { print } from "../utils.ts"; 11import { Hsh } from "../hsh.ts"; 12import { Notebook } from "../notebook.ts"; 13 14function register( 15 cmd: Command, 16 hsh: Hsh, 17) { 18 cmd 19 .command("info", "grab information about a note") 20 .arguments("<note:string>") 21 .action(async (_opts, path) => { 22 const p = await hsh.resolve(path); 23 const root = p.notebook.root; 24 const creationDate = await creationDateFor(root, p.toString()); 25 const modificationDate = await modificationDateFor(root, p.toString()); 26 27 print(dedent(` 28 File : ${p.entry} 29 Created : ${creationDate.toLocaleString()} 30 Modified: ${modificationDate.toLocaleString()} 31 `)); 32 }); 33 34 hsh.addHandler({ 35 handleNotebookChanged: async (notebook: Notebook, message: string) => { 36 await commit(notebook, message); 37 await syncNotebook(notebook); 38 }, 39 }); 40} 41 42export default { register };