the tangled network observatory ◈ every knot, its health, its version, in your terminal
tangled cli tui knot monitoring observability atproto federation
0

Configure Feed

Select the types of activity you want to include in your feed.

feat: colorize help output

+25 -3
+23 -2
src/cli.ts
··· 1 1 #!/usr/bin/env node 2 2 import { readFileSync } from "node:fs"; 3 + import { styleText } from "node:util"; 3 4 import { parse } from "@bomb.sh/args"; 4 5 import { animateBanner } from "./banner.js"; 5 6 ··· 23 24 fid --version print the version 24 25 `; 25 26 27 + // colors go in after the columns are padded, so alignment math never sees ansi 28 + const colorUsage = (s: string) => 29 + s 30 + .split("\n") 31 + .map((line) => { 32 + if (line === "usage:") return styleText("dim", line); 33 + const m = /^(\s+)(\S.*?)(\s{2,})(.*)$/.exec(line); 34 + if (!m) return line; 35 + const [, indent, left, gap, desc] = m; 36 + const colored = left 37 + .replace( 38 + /^fid (?!--)(\S+)/, 39 + (_, cmd: string) => `fid ${styleText(["green", "bold"], cmd)}`, 40 + ) 41 + .replace(/--[\w-]+/g, (f) => styleText("cyan", f)) 42 + .replace(/<[^>]+>/g, (a) => styleText("magenta", a)); 43 + return indent + colored + gap + styleText("dim", desc); 44 + }) 45 + .join("\n"); 46 + 26 47 if (args.version) { 27 48 const pkg = JSON.parse( 28 49 readFileSync(new URL("../package.json", import.meta.url), "utf8"), ··· 36 57 if (!args.json && command !== "watch") await animateBanner(); 37 58 38 59 if (args.help || !command) { 39 - console.log(usage); 60 + console.log(colorUsage(usage)); 40 61 process.exit(command ? 0 : 1); 41 62 } 42 63 ··· 64 85 break; 65 86 default: 66 87 console.error(`unknown command: ${command}\n`); 67 - console.log(usage); 88 + console.log(colorUsage(usage)); 68 89 process.exit(1); 69 90 }
+2 -1
src/tui/board.ts
··· 142 142 .entries()) { 143 143 const index = state.offset + i; 144 144 const selected = index === state.selected; 145 - const flashedAgo = now - (state.changed.get(row.host) ?? Number.NEGATIVE_INFINITY); 145 + const flashedAgo = 146 + now - (state.changed.get(row.host) ?? Number.NEGATIVE_INFINITY); 146 147 const flashing = flashedAgo < FLASH_MS; 147 148 ops.push( 148 149 open(`row-${row.host}`, {