import type { DatabaseSync } from "node:sqlite"; import { Checkbox } from "@cliffy/prompt"; import { Table } from "@cliffy/table"; import { getGroceryList, getRecipesList } from "../services.ts"; export default async (db: DatabaseSync) => { const recipes = getRecipesList(db); const choices = await Checkbox.prompt({ message: "Select recipes", options: recipes.map((recipe) => ({ name: recipe.name as string, value: recipe.id, })), }); const ingredients = getGroceryList(db, choices as number[]); const table = new Table( ...ingredients.map((item) => [item.name, item.quantity, item.unit]) ).header(["Name", "Quantity", "Unit"]); console.log(table.border().sort().toString()); };