diff --git a/src/format.ts b/src/format.ts index a54b193..90db866 100644 --- a/src/format.ts +++ b/src/format.ts @@ -3,17 +3,17 @@ import type { Stats } from "./store.js"; export type OutputFormat = "table" | "json" | "csv" | "md"; -export const OUTPUT_FORMATS: OutputFormat[] = ["table", "json", "csv", "md"]; +const OUTPUT_FORMATS: OutputFormat[] = ["table", "json", "csv", "md"]; export function isOutputFormat(value: string): value is OutputFormat { return (OUTPUT_FORMATS as string[]).includes(value); } -export function padRight(text: string, width: number): string { +function padRight(text: string, width: number): string { return text.length >= width ? text : text + " ".repeat(width - text.length); } -export function padLeft(text: string, width: number): string { +function padLeft(text: string, width: number): string { return text.length >= width ? text : " ".repeat(width - text.length) + text; } @@ -53,7 +53,7 @@ export function renderTable(rows: string[][], headers?: string[]): string { return lines.join("\n"); } -export function itemsToTable(items: Item[], today: Date = new Date()): string { +function itemsToTable(items: Item[], today: Date = new Date()): string { const rows = items.map((i) => [ i.id, truncate(i.name, 32), @@ -65,7 +65,7 @@ export function itemsToTable(items: Item[], today: Date = new Date()): string { return renderTable(rows, ["ID", "NAME", "QTY", "CATEGORY", "EXPIRES", "TAGS"]); } -export function itemsToJson(items: Item[]): string { +function itemsToJson(items: Item[]): string { return JSON.stringify(items, null, 2); } @@ -87,7 +87,7 @@ export function itemsToCsv(items: Item[]): string { return lines.join("\n"); } -export function itemsToMarkdown(items: Item[], today: Date = new Date()): string { +function itemsToMarkdown(items: Item[], today: Date = new Date()): string { const lines = ["| id | name | qty | category | expires | tags |", "|---|---|---|---|---|---|"]; for (const i of items) { lines.push(