From 1bb019205d0deb2c6125ec29eef3e603c4f3d332 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Thu, 16 Apr 2026 01:10:20 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=84=20Update=20script=20metadata=20and?= =?UTF-8?q?=20improve=20argument=20parsing=20in=20init-tsscript.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-meta-v2.json | 6 +++--- single-scripts/init-tsscript.ts | 24 ++++++++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/script-meta-v2.json b/script-meta-v2.json index 79663b0..0e4ef2f 100644 --- a/script-meta-v2.json +++ b/script-meta-v2.json @@ -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", diff --git a/single-scripts/init-tsscript.ts b/single-scripts/init-tsscript.ts index fb40980..5f7e502 100755 --- a/single-scripts/init-tsscript.ts +++ b/single-scripts/init-tsscript.ts @@ -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 { +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 { + 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