🔄 Update script metadata and improve argument parsing in init-tsscript.ts

This commit is contained in:
2026-04-16 01:10:20 +08:00
parent 9eeadaf7e9
commit 1bb019205d
2 changed files with 21 additions and 9 deletions

View File

@@ -180,12 +180,12 @@
},
"init-tsscript.ts": {
"script_name": "init-tsscript.ts",
"script_length": 2078,
"script_sha256": "2e9c9c6d44f1a2b5c8899c20439397f91caa97fa6f573e550ca589ca9bbf7cac",
"script_length": 2231,
"script_sha256": "955eb7e417f81f2f47314fce0509a39ce5cfcf28738534c13db0cb57566fe4a8",
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/init-tsscript.ts",
"single_script_file": true,
"publish_time": 1776008182540,
"update_time": 1776272822216
"update_time": 1776273009816
},
"ip.ts": {
"script_name": "ip.ts",

View File

@@ -1,11 +1,19 @@
#!/usr/bin/env runts -- --allow-all
import {parseArgs} from "jsr:@std/cli/parse-args";
import {existsPath, exit, log, writeStringToFile,} from "https://script.hatter.ink/@70/deno-commons-mod.ts";
import { parseArgs } from "jsr:@std/cli/parse-args";
import {
existsPath,
exit,
log,
writeStringToFile,
} from "https://script.hatter.ink/@70/deno-commons-mod.ts";
async function main(): Promise<void> {
function parseFlags(): any {
const flags = parseArgs(Deno.args, {
boolean: ["help"],
alias: {
h: "help",
},
});
if (flags.help) {
console.log(`init-tsscript.ts - Init TypeScript script file
@@ -14,13 +22,17 @@ init-tsscript.ts [SCRIPT_NAME]
`);
exit(0);
}
return flags;
}
async function main(): Promise<void> {
const flags = parseFlags();
const name = (flags._ && flags._.length > 0)
? flags._[0]
: prompt("Script name:");
if (!name) {
log.error("Script name is required");
return;
exit(1);
}
let scriptFile = name;
if (!name.endsWith(".ts")) {
@@ -82,5 +94,5 @@ main().catch((err) => {
exit(1);
}).then(() => exit(0));
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260416T010643+08:00.MEYCIQCAzfRe5exq023/xi+1
// i2xAdACp+B2Q5b6tVkGpdrvrlgIhANQZPKALwdaRNgG2SkckWZxonnaMwbVCjyjFYmq/FXqb
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260416T010940+08:00.MEYCIQC1kDn6UCQqBl2YXsi1
// SLZamJIx/SGZgyMQIRWzehDFxgIhALE3TYPe5C6iDPw/RRs0tS+7HXXL/uT/6lNBuG8jsNwO