UNPKG

@taml/cli

Version:

CLI tool to convert ANSI escape sequences to TAML (Terminal ANSI Markup Language) tags

46 lines (37 loc) 969 B
#!/usr/bin/env node import { encode } from "@taml/encoder"; /** * Read all input from STDIN */ async function readStdin(): Promise<string> { const chunks: Buffer[] = []; for await (const chunk of process.stdin) { chunks.push(chunk); } return Buffer.concat(chunks).toString("utf8"); } /** * CLI entry point for taml-cli converter */ async function main() { try { // Read from STDIN const input = await readStdin(); if (!input || !input.trim()) { console.error( "Error: No input provided. Please pipe ANSI text to this command.", ); console.error("Usage: cat file.txt | taml-cli"); console.error(' echo -e "\\e[31mRed text\\e[0m" | taml-cli'); process.exit(1); } // Convert ANSI to TAML const output = encode(input); // Write to STDOUT console.log(output); } catch (error) { console.error("Error processing ANSI text:", error); process.exit(1); } } main();