import { select } from "@topcli/prompts"; import type { AppletRunFunc } from "./Applet.ts"; import { ExitApplet } from "./applets/Exit.ts"; import { UnfoldedHexToSonyApplet } from "./applets/UnfoldedHexToSony.ts"; import { SonyToUnfoldedHexApplet } from "./applets/SonyToUnfoldedHex.ts"; const applets = [SonyToUnfoldedHexApplet, UnfoldedHexToSonyApplet, ExitApplet]; const appletNames = applets.map((applet) => applet.name); const appletsMap = applets.reduce( (map, applet) => map.set(applet.name, applet.runFunc), new Map(), ); while (true) { const selectedAppletName = await select("What would you like to do?", { choices: appletNames, }); await appletsMap.get(selectedAppletName)!(); }