fix: banana
This commit is contained in:
parent
43d5916e52
commit
4f043d2bd7
22
cli/index.ts
22
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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user