From 4f043d2bd767fe5a5f8abde724822f1589423302 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 7 May 2025 13:07:47 -0600 Subject: [PATCH] fix: banana --- cli/index.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/cli/index.ts b/cli/index.ts index 9decc4e..39476a5 100644 --- a/cli/index.ts +++ b/cli/index.ts @@ -6,8 +6,6 @@ import { selectMenuInteractive } from "./selectMenu.ts"; import { TerminalBlock, TerminalLayout } from "./TerminalLayout.ts"; import { cliAlert, cliLog } from "./prompts.ts"; import type { ITool } from "../types.ts"; -import { join, toFileUrl } from "@std/path"; -import { log } from "util/logfile.ts"; // Register tools here (filename, no extension) const toolRegistry: [string, Promise<{ default: ITool }>][] = [ @@ -23,6 +21,7 @@ export class PdfToolsCli { private args = ArgParser.parse(Deno.args).setFlagDefs({ help: ["-h", "--help"], + banana: ["-b", "--banana"], }); async importTools() { @@ -43,9 +42,7 @@ export class PdfToolsCli { private async banana() { const asciiArt = await getAsciiArt("banana"); - const body = this.terminalLayout.getBlock("body"); - body.clearAll(); - cliLog(colorize(asciiArt, "yellow"), body); + this.closeMessage = colorize(asciiArt, "yellow"); } private async help() { @@ -64,6 +61,11 @@ export class PdfToolsCli { this.terminalLayout.register("title", titleBlock); const bodyBlock = new TerminalBlock(); this.terminalLayout.register("body", bodyBlock); + if (this.args.getFlag("banana")) { + titleBlock.setFixedHeight(0); + await this.banana(); + return; + } if (this.args.getFlag("help") && !this.args.task) { await this.help(); return; @@ -75,12 +77,16 @@ export class PdfToolsCli { await this.runTool(toCase(task, "title")); } } finally { - this.terminalLayout.clearAll(); - Deno.stdin.setRaw(false); - if (this.closeMessage) console.log(this.closeMessage); + this.cleanup(); } } + private cleanup() { + this.terminalLayout.clearAll(); + Deno.stdin.setRaw(false); + if (this.closeMessage) console.log(this.closeMessage); + } + private async toolMenu() { const tools = this.tools.keys().toArray(); const bodyBlock = this.terminalLayout.getBlock("body");