This commit is contained in:
2026-02-08 14:47:09 +08:00
parent d1c5db0e07
commit 8c3014394f
2 changed files with 54 additions and 3 deletions

42
single-scripts/term-color.ts Executable file
View File

@@ -0,0 +1,42 @@
#!/usr/bin/env runts -- --allow-import
import {term} from "https://script.hatter.ink/@32/deno-commons-mod.ts";
function printColors(colors: string[], prefix: string, suffix: string) {
const termOutputs = [];
for (const color of colors) {
termOutputs.push(
term.auto(
`[${prefix}${color}${suffix}][[[[${prefix}${color}${suffix}] Hello World! [/${prefix}${color}${suffix}]]]][/] `,
),
);
}
console.log(termOutputs.join(" "));
}
async function main() {
const colors = [
"black",
"red",
"green",
"yellow",
"blue",
"pink",
"cyan",
"white",
];
printColors(colors, "", "");
console.log();
printColors(colors, "", "_bright");
console.log();
printColors(colors, "bg_", "");
console.log();
printColors(colors, "bg_", "_bright");
console.log();
console.log(term.auto('[bg_black][white][bold]Bold, white and black background [/][/][/]'));
console.log(term.auto('[black][bg_white][bold]Bold, black and white background [/][/][/]'));
}
await main();
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260208T144636+08:00.MEUCIQCyWJ2Yiijq3QYzuGXC
// uF1MfCW1yjFC5LmxDXQwGs8efgIgD6Xfh/4jUoDMjhRhp2itj9juT4PkGkP2u+9AhBZo1hY=