import { Command } from "@cliffy/command"; import { addFolder, moveItem, removeFolder } from "../folders.ts"; import { Hsh } from "../hsh.ts"; function register(cmd: Command, hsh: Hsh) { cmd .command("move", "move a note") .alias("mv") .alias("mi") .arguments(" ") .action(async (_opts, origin, destination) => { const source = await hsh.resolve(origin); const target = hsh.parse(destination, false); if (source.entry != null && target.entry == null) { target.entry = source.entry; } await moveItem(source, target, hsh); }); cmd.command("folder", getFolderCommands(hsh)); } function getFolderCommands(hsh: Hsh) { return new Command() .description("add, remove and move folders") .action(function () { this.showHelp(); }) .command("add", "add folder") .alias("a") .arguments("") .action(async (_options, path) => { await addFolder(hsh.parse(path, false), hsh); }) .command("remove", "remove a folder") .alias("rm") .option("-f, --force", "force removal", { default: false }) .arguments("") .action(async ({ force }, path) => { await removeFolder(hsh.parse(path), force, hsh); }); } export default { register };