#!/bin/env -S deno run import { crayon } from "https://deno.land/x/crayon@3.3.3/mod.ts"; async function read_line() { const buf = new Uint8Array(1024); const n = await Deno.stdin.read(buf); if (n === null) return null; const line = new TextDecoder().decode(buf.subarray(0, n)); return line; } function pick(arr: T[]) { const index = Math.floor(arr.length * Math.random()); return arr[index]; } const [prefix] = Deno.args; const colors = [ crayon.red, crayon.green, crayon.blue, crayon.yellow, crayon.magenta, ]; const color = pick(colors); while (true) { let line = await read_line(); if (line == null) break; line = line.substring(0, line.length - 1); console.log(`${color(`[${prefix}]`)} ${line}`); }