diff --git a/libraries/deno-commons-mod.ts b/libraries/deno-commons-mod.ts index c991352..c8a6a9d 100644 --- a/libraries/deno-commons-mod.ts +++ b/libraries/deno-commons-mod.ts @@ -1,8 +1,8 @@ // Reference: // - https://docs.deno.com/runtime/fundamentals/testing/ -import {decodeBase64, encodeBase64} from "jsr:@std/encoding/base64"; -import {dirname, fromFileUrl} from "https://deno.land/std/path/mod.ts"; +import { decodeBase64, encodeBase64 } from "jsr:@std/encoding/base64"; +import { dirname, fromFileUrl } from "https://deno.land/std/path/mod.ts"; // reference: https://docs.deno.com/examples/hex_base64_encoding/ // import { decodeBase64, encodeBase64 } from "jsr:@std/encoding/base64"; @@ -337,6 +337,11 @@ function renderColorTokens(tokens: ColorToken[]): string { if (token.type === "color") { const color = token.color; if (color) { + const colorCode = COLOR_MAP[color]; + if (!colorCode) { + text.push(`[${token.colorStart ? "" : "/"}${color}]`); + continue; + } const colorStack = colorMapStack.get(color) ?? []; if (colorStack.length == 0) { colorMapStack.set(color, colorStack); @@ -350,10 +355,7 @@ function renderColorTokens(tokens: ColorToken[]): string { const colors: string[] = []; for (const [color, colorStack] of colorMapStack) { if (colorStack.length > 0) { - const colorCode = COLOR_MAP[color]; - if (colorCode) { - colors.push(colorCode); - } + colors.push(colorCode); } } if (colors.length > 0) { diff --git a/python-ts/main.ts b/python-ts/main.ts index 15152d0..2562026 100755 --- a/python-ts/main.ts +++ b/python-ts/main.ts @@ -11,7 +11,7 @@ import { resolveFilename, term, writeStringToFile, -} from "https://global.hatter.ink/script/get/@18/deno-commons-mod.ts"; +} from "https://global.hatter.ink/script/get/@27/deno-commons-mod.ts"; import {parseArgs} from "jsr:@std/cli/parse-args"; import {assertEquals} from "jsr:@std/assert"; @@ -88,42 +88,18 @@ async function savePythonConfig(pythonConfig: PythonConfig): Promise { } function handleHelp(_args: string[]) { - const help = []; - help.push( - `${ - term.green("python.ts") - } - Python version and virtual environment management tool + const help = + `[green]python.ts[/green] - Python version and virtual environment management tool -${term.green("python.ts")} ${ - term.bold("python") - } - management python version ${ - term.yellow("[alias: py, ver, version]") - } -${term.green("python.ts")} ${term.bold("add-python")} - add python version ${ - term.yellow("[alias: add-py]") - } -${term.green("python.ts")} ${ - term.bold("venv") - } - management python virtual environment ${ - term.yellow("[alias: env]") - } -${term.green("python.ts")} ${ - term.bold("add-venv") - } - add python virtual environment ${term.yellow("[alias: add-env]")} -${term.green("python.ts")} ${ - term.bold("remove-venv") - } - remove python virtual environment ${ - term.yellow("[alias: rm-venv, rm-env]") - } -${term.green("python.ts")} ${ - term.bold("active-venv") - } - active python virtual environment ${ - term.yellow("[alias: active, active-env]") - }`, - ); +[green]python.ts[/green] [bold]python[/bold] - management python version [yellow]\\[alias: py, ver, version][/yellow] +[green]python.ts[/green] [bold]add-python[/bold] - add python version [yellow]\\[alias: add-py][/yellow] +[green]python.ts[/green] [bold]env[/bold] - management python virtual environment [yellow]\\[alias: env][/yellow] +[green]python.ts[/green] [bold]add-venv[/bold] - add python virtual environment [yellow]\\[alias: add-env][/yellow] +[green]python.ts[/green] [bold]remove-venv[/bold] - remove python virtual environment [yellow]\\[alias: rm-venv, rm-env][/yellow] +[green]python.ts[/green] [bold]active-venv[/bold] - active python virtual environment [yellow]\\[alias: active, active-env][/yellow]`; // source <(cat ~/.venv-python-3.13.5/bin/activate) // source <(python.ts venv test1) - console.log(help.join("\n")); + console.log(term.auto(help)); } async function addVirtualEnv( @@ -237,20 +213,24 @@ async function handlePython(args: string[]) { } versions.sort(versionSort); - console.log(`Found ${versions.length} Python version(s)`); + console.log( + term.auto( + `Found [bold][green]${versions.length}[/green][/bold] Python version${ + versions.length == 1 ? "" : "s" + }:`, + ), + ); for (const version of versions) { const pythonVersion = pythonConfig.versions[version]; const versionPadding = " ".repeat( maxVersionLength - version.length, ); console.log( - "-", - "version:", - term.green(term.bold(version)), - ";path:", - term.blue(pythonVersion.path), - ";comment:", - term.yellow(term.under(pythonVersion.comment)), + term.auto( + `- version: [green][bold]${version}[/green][/bold]` + + `; path: [blue]${pythonVersion.path}[/blue]` + + `; comment: [yellow][under]${pythonVersion.comment}[/under][/yellow]`, + ), ); // console.log("- Python:", version, pythonVersion,); } @@ -361,7 +341,7 @@ python.ts venv [--name|-n filter-name]`); filterProfilesCount++; console.log( "-", - term.blue(term.bold(term.under(venv))), + term.auto(`[blue][under][bold]${venv}[/bold][/under][/blue]`), term.yellow( pythonVenvProfile.alias ? `[alias: ${pythonVenvProfile.alias.join(", ")}]` @@ -546,5 +526,5 @@ Deno.test("versionSort", () => { assertEquals(["3.7", "3.10", "3.10.1", "3.11"], versions2); }); -// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260127T224153+08:00.MEUCIQCuTKNb0y+N137tvQw+ -// 47AFPWoCz5WaUSCJOUpcQBKDNwIgFxvsWvHCgWh5jpCjoQWURwLjAHsN9ze5K5X7KkVUuEM= +// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260205T232313+08:00.MEQCIHC9xGfzR6iiMjJjpPAc +// lJ3lyEUT5a+7qLUml7HcEV6WAiA7ZZ5yUdtfk0J0zQBnam92VOHjYvH2sLrVBI/88vB1sQ==