update python.ts
This commit is contained in:
@@ -235,6 +235,10 @@ class Term {
|
|||||||
return `\x1b[1m${message}\x1b[0m`;
|
return `\x1b[1m${message}\x1b[0m`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
under(message: string): string {
|
||||||
|
return `\x1b[4m${message}\x1b[0m`;
|
||||||
|
}
|
||||||
|
|
||||||
red(message: string): string {
|
red(message: string): string {
|
||||||
return `\x1b[31m${message}\x1b[0m`;
|
return `\x1b[31m${message}\x1b[0m`;
|
||||||
}
|
}
|
||||||
@@ -246,6 +250,18 @@ class Term {
|
|||||||
yellow(message: string): string {
|
yellow(message: string): string {
|
||||||
return `\x1b[33m${message}\x1b[0m`;
|
return `\x1b[33m${message}\x1b[0m`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blue(message: string): string {
|
||||||
|
return `\x1b[34m${message}\x1b[0m`;
|
||||||
|
}
|
||||||
|
|
||||||
|
pink(message: string): string {
|
||||||
|
return `\x1b[35m${message}\x1b[0m`;
|
||||||
|
}
|
||||||
|
|
||||||
|
cyan(message: string): string {
|
||||||
|
return `\x1b[36m${message}\x1b[0m`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const term = new Term();
|
export const term = new Term();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
resolveFilename,
|
resolveFilename,
|
||||||
term,
|
term,
|
||||||
writeStringToFile,
|
writeStringToFile,
|
||||||
} from "https://global.hatter.ink/script/get/@16/deno-commons-mod.ts";
|
} from "https://global.hatter.ink/script/get/@18/deno-commons-mod.ts";
|
||||||
import {parseArgs} from "jsr:@std/cli/parse-args";
|
import {parseArgs} from "jsr:@std/cli/parse-args";
|
||||||
import {assertEquals} from "jsr:@std/assert";
|
import {assertEquals} from "jsr:@std/assert";
|
||||||
|
|
||||||
@@ -33,6 +33,7 @@ interface PythonVersion {
|
|||||||
interface PythonVenv {
|
interface PythonVenv {
|
||||||
version: string;
|
version: string;
|
||||||
path: string;
|
path: string;
|
||||||
|
alias?: string[];
|
||||||
comment?: string;
|
comment?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,6 +129,7 @@ ${term.green("python.ts")} ${
|
|||||||
async function addVirtualEnv(
|
async function addVirtualEnv(
|
||||||
pythonVersion: string | null,
|
pythonVersion: string | null,
|
||||||
pythonVenv: string,
|
pythonVenv: string,
|
||||||
|
alias?: string,
|
||||||
comment?: string,
|
comment?: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const pythonConfig = await loadPythonConfig();
|
const pythonConfig = await loadPythonConfig();
|
||||||
@@ -184,6 +186,9 @@ async function addVirtualEnv(
|
|||||||
comment ? (", user comment: " + comment) : ""
|
comment ? (", user comment: " + comment) : ""
|
||||||
}`,
|
}`,
|
||||||
};
|
};
|
||||||
|
if (alias) {
|
||||||
|
newPythonVenvProfile.alias = [alias];
|
||||||
|
}
|
||||||
if (!pythonConfig.profiles) {
|
if (!pythonConfig.profiles) {
|
||||||
pythonConfig.profiles = {};
|
pythonConfig.profiles = {};
|
||||||
}
|
}
|
||||||
@@ -239,10 +244,15 @@ async function handlePython(args: string[]) {
|
|||||||
maxVersionLength - version.length,
|
maxVersionLength - version.length,
|
||||||
);
|
);
|
||||||
console.log(
|
console.log(
|
||||||
"- Python:",
|
"-",
|
||||||
version,
|
"version:",
|
||||||
pythonVersion,
|
term.green(term.bold(version)),
|
||||||
|
";path:",
|
||||||
|
term.blue(pythonVersion.path),
|
||||||
|
";comment:",
|
||||||
|
term.yellow(term.under(pythonVersion.comment)),
|
||||||
);
|
);
|
||||||
|
// console.log("- Python:", version, pythonVersion,);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,10 +361,15 @@ python.ts venv [--name|-n filter-name]`);
|
|||||||
filterProfilesCount++;
|
filterProfilesCount++;
|
||||||
console.log(
|
console.log(
|
||||||
"-",
|
"-",
|
||||||
venv,
|
term.blue(term.bold(term.under(venv))),
|
||||||
|
term.yellow(
|
||||||
|
pythonVenvProfile.alias
|
||||||
|
? `[alias: ${pythonVenvProfile.alias.join(", ")}]`
|
||||||
|
: "-",
|
||||||
|
),
|
||||||
pythonVenvProfile,
|
pythonVenvProfile,
|
||||||
`, active virtual environment command: ${
|
`, active virtual environment command: ${
|
||||||
term.green("source <(python.ts active-venv " + venv + ")")
|
term.under("source <(python.ts active " + venv + ")")
|
||||||
}`,
|
}`,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -373,7 +388,7 @@ python.ts venv [--name|-n filter-name]`);
|
|||||||
async function handleAddVenv(args: string[]) {
|
async function handleAddVenv(args: string[]) {
|
||||||
const flags = parseArgs(args, {
|
const flags = parseArgs(args, {
|
||||||
boolean: ["help"],
|
boolean: ["help"],
|
||||||
string: ["version", "venv", "comment"],
|
string: ["version", "venv", "comment", "alias"],
|
||||||
alias: {
|
alias: {
|
||||||
V: "version",
|
V: "version",
|
||||||
c: "comment",
|
c: "comment",
|
||||||
@@ -393,7 +408,7 @@ python.ts add-venv --version 3.10 --venv test-env [--comment comment]`);
|
|||||||
log.error("Venv is missing");
|
log.error("Venv is missing");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await addVirtualEnv(flags.version, flags.venv, flags.comment);
|
await addVirtualEnv(flags.version, flags.venv, flags.alias, flags.comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleRemoveVenv(args: string[]) {
|
async function handleRemoveVenv(args: string[]) {
|
||||||
@@ -531,5 +546,5 @@ Deno.test("versionSort", () => {
|
|||||||
assertEquals(["3.7", "3.10", "3.10.1", "3.11"], versions2);
|
assertEquals(["3.7", "3.10", "3.10.1", "3.11"], versions2);
|
||||||
});
|
});
|
||||||
|
|
||||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260127T221900+08:00.MEYCIQC/ePZbN/H3JAOhZ43u
|
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260127T224153+08:00.MEUCIQCuTKNb0y+N137tvQw+
|
||||||
// 4ek90MK1IFKLKTynP9RHYRgxTAIhALWtaXAarv25CKcd1ok4AYfuw5ooR68smBzOokmBsEfI
|
// 47AFPWoCz5WaUSCJOUpcQBKDNwIgFxvsWvHCgWh5jpCjoQWURwLjAHsN9ze5K5X7KkVUuEM=
|
||||||
|
|||||||
@@ -168,11 +168,11 @@
|
|||||||
},
|
},
|
||||||
"python.ts": {
|
"python.ts": {
|
||||||
"script_name": "python.ts",
|
"script_name": "python.ts",
|
||||||
"script_length": 16299,
|
"script_length": 16879,
|
||||||
"script_sha256": "774cde4fc706489444e4ba0a88bb5db16cb8fe3f16ea37d1468d9ff4e8b78975",
|
"script_sha256": "c1a526302f1f72801fa73b6dba5dca5929cdbe5d578f44691bbcf898c559444d",
|
||||||
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/python-ts/main.ts",
|
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/python-ts/main.ts",
|
||||||
"publish_time": 1768236234264,
|
"publish_time": 1768236234264,
|
||||||
"update_time": 1769523568468
|
"update_time": 1769524924109
|
||||||
},
|
},
|
||||||
"random.ts": {
|
"random.ts": {
|
||||||
"script_name": "random.ts",
|
"script_name": "random.ts",
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
},
|
},
|
||||||
"python-ts": {
|
"python-ts": {
|
||||||
"script_name": "python-ts",
|
"script_name": "python-ts",
|
||||||
"script_length": 16299,
|
"script_length": 16879,
|
||||||
"script_sha256": "774cde4fc706489444e4ba0a88bb5db16cb8fe3f16ea37d1468d9ff4e8b78975"
|
"script_sha256": "c1a526302f1f72801fa73b6dba5dca5929cdbe5d578f44691bbcf898c559444d"
|
||||||
},
|
},
|
||||||
"sigstore-verify-ts": {
|
"sigstore-verify-ts": {
|
||||||
"script_name": "sigstore-verify-ts",
|
"script_name": "sigstore-verify-ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user