fix: banana

This commit is contained in:
Emmaline Autumn 2025-05-07 13:07:47 -06:00
parent 43d5916e52
commit 4f043d2bd7

View File

@ -6,8 +6,6 @@ import { selectMenuInteractive } from "./selectMenu.ts";
import { TerminalBlock, TerminalLayout } from "./TerminalLayout.ts"; import { TerminalBlock, TerminalLayout } from "./TerminalLayout.ts";
import { cliAlert, cliLog } from "./prompts.ts"; import { cliAlert, cliLog } from "./prompts.ts";
import type { ITool } from "../types.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) // Register tools here (filename, no extension)
const toolRegistry: [string, Promise<{ default: ITool }>][] = [ const toolRegistry: [string, Promise<{ default: ITool }>][] = [
@ -23,6 +21,7 @@ export class PdfToolsCli {
private args = ArgParser.parse(Deno.args).setFlagDefs({ private args = ArgParser.parse(Deno.args).setFlagDefs({
help: ["-h", "--help"], help: ["-h", "--help"],
banana: ["-b", "--banana"],
}); });
async importTools() { async importTools() {
@ -43,9 +42,7 @@ export class PdfToolsCli {
private async banana() { private async banana() {
const asciiArt = await getAsciiArt("banana"); const asciiArt = await getAsciiArt("banana");
const body = this.terminalLayout.getBlock("body"); this.closeMessage = colorize(asciiArt, "yellow");
body.clearAll();
cliLog(colorize(asciiArt, "yellow"), body);
} }
private async help() { private async help() {
@ -64,6 +61,11 @@ export class PdfToolsCli {
this.terminalLayout.register("title", titleBlock); this.terminalLayout.register("title", titleBlock);
const bodyBlock = new TerminalBlock(); const bodyBlock = new TerminalBlock();
this.terminalLayout.register("body", bodyBlock); 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) { if (this.args.getFlag("help") && !this.args.task) {
await this.help(); await this.help();
return; return;
@ -75,12 +77,16 @@ export class PdfToolsCli {
await this.runTool(toCase(task, "title")); await this.runTool(toCase(task, "title"));
} }
} finally { } finally {
this.terminalLayout.clearAll(); this.cleanup();
Deno.stdin.setRaw(false);
if (this.closeMessage) console.log(this.closeMessage);
} }
} }
private cleanup() {
this.terminalLayout.clearAll();
Deno.stdin.setRaw(false);
if (this.closeMessage) console.log(this.closeMessage);
}
private async toolMenu() { private async toolMenu() {
const tools = this.tools.keys().toArray(); const tools = this.tools.keys().toArray();
const bodyBlock = this.terminalLayout.getBlock("body"); const bodyBlock = this.terminalLayout.getBlock("body");