From 40e132c0df8a9260299dcda84016c3c3700915be Mon Sep 17 00:00:00 2001 From: Bauke Date: Sun, 5 Mar 2023 16:10:30 +0100 Subject: [PATCH] Begin on the bulk move subcommand. --- .bauke/scripts/bulk/bulk.ts | 2 ++ .bauke/scripts/bulk/move.ts | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 .bauke/scripts/bulk/move.ts diff --git a/.bauke/scripts/bulk/bulk.ts b/.bauke/scripts/bulk/bulk.ts index 0c136d4..df4b217 100644 --- a/.bauke/scripts/bulk/bulk.ts +++ b/.bauke/scripts/bulk/bulk.ts @@ -1,10 +1,12 @@ import { Command } from "../dependencies.ts"; +import { moveCommand } from "./move.ts"; import { runCommand } from "./run.ts"; async function main(): Promise { await new Command() .name("bulk") .description("Bulk doer of things.") + .command("move", moveCommand) .command("run", runCommand) .parse(Deno.args); } diff --git a/.bauke/scripts/bulk/move.ts b/.bauke/scripts/bulk/move.ts new file mode 100644 index 0000000..e2a2dd9 --- /dev/null +++ b/.bauke/scripts/bulk/move.ts @@ -0,0 +1,33 @@ +import { Command, prompt } from "../dependencies.ts"; + +export const moveCommand = new Command() + .name("move") + .description("Interactively move a group of files.") + .option( + "-d, --directory ", + "Directories to include files from.", + { + collect: true, + }, + ) + .action(async ({ + directory, + }) => { + await actionHandler({ directories: directory ?? [] }); + }); + +async function actionHandler( + options: { + directories: string[]; + }, +): Promise { + for (const directory of options.directories) { + for await (const file of Deno.readDir(directory)) { + if (!file.isFile) { + continue; + } + + console.log(file); + } + } +}