From 65889c72c74c37bc1ccf6b837b8b91fbac7059c7 Mon Sep 17 00:00:00 2001 From: Ethan Date: Tue, 9 Feb 2021 17:43:04 -0800 Subject: [PATCH] created ninja-logs cli --- ninja-logs/README.md | 2 +- ninja-logs/cli.ts | 18 ++++++++++++++++++ ninja-logs/mod.ts | 16 ++++++++++++++++ ninja-logs/nl.ts | 16 ---------------- ninja-logs/templates/white/coconut-chaos.md | 3 ++- 5 files changed, 37 insertions(+), 18 deletions(-) create mode 100644 ninja-logs/cli.ts create mode 100644 ninja-logs/mod.ts delete mode 100644 ninja-logs/nl.ts diff --git a/ninja-logs/README.md b/ninja-logs/README.md index e25e80b..531480a 100644 --- a/ninja-logs/README.md +++ b/ninja-logs/README.md @@ -3,5 +3,5 @@ ## Usage ```sh -deno install https://github.com/EthanThatOneKid/code-sensei/main/blob/ninja-logs/mod.ts +deno run --unstable --allow-read cli.ts ``` diff --git a/ninja-logs/cli.ts b/ninja-logs/cli.ts new file mode 100644 index 0000000..a210ffd --- /dev/null +++ b/ninja-logs/cli.ts @@ -0,0 +1,18 @@ +import { Command } from "https://deno.land/x/cliffy@v0.17.2/command/mod.ts"; +import ninjaLogs from "./mod.ts"; + +const main = async () => { + const { options } = await new Command() + .name("nl") + .version("0.0.1") + .description("command line interface for deno") + .option("-t, --template", "path of desired template", { required: true }) + .parse(Deno.args); + await ninjaLogs({ template: options.template }); +}; + +if (import.meta.main) { + await main(); +} + +export default main; diff --git a/ninja-logs/mod.ts b/ninja-logs/mod.ts new file mode 100644 index 0000000..8aadd56 --- /dev/null +++ b/ninja-logs/mod.ts @@ -0,0 +1,16 @@ +import { walk } from "https://deno.land/std/fs/mod.ts"; + +interface Config { + template: string; +} + +export default async function (config: Config): Promise { + let templatePath = ""; + for await (const entry of walk("./templates/")) { + if (entry.path.replace(/\\+/g, "/").includes(config.template)) { + templatePath = entry.path; + break; + } + } + console.log({ templatePath }); +} diff --git a/ninja-logs/nl.ts b/ninja-logs/nl.ts deleted file mode 100644 index 5012fec..0000000 --- a/ninja-logs/nl.ts +++ /dev/null @@ -1,16 +0,0 @@ -// filename: "nl" -// `nl` is short for "Ninja Logs" - -import { Command } from "https://deno.land/x/cliffy@v0.17.2/command/mod.ts"; - -const main = async () => { - await new Command() - .name("nl") - .version("0.0.1") - .description("Command line interface for Deno") - .parse(Deno.args); -}; - -if (import.meta.main) { - await main(); -} diff --git a/ninja-logs/templates/white/coconut-chaos.md b/ninja-logs/templates/white/coconut-chaos.md index bb86cff..6379c28 100644 --- a/ninja-logs/templates/white/coconut-chaos.md +++ b/ninja-logs/templates/white/coconut-chaos.md @@ -1 +1,2 @@ -Coconut chaos is awesome. +Today, your child, {NAME}, completed the game, Coconut Chaos. +They did an awesome job!