From e216014d27f100535d7c3022df5ae91be0953949 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 12 Apr 2026 13:56:20 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9A=20Update=20script=20metadata=20and?= =?UTF-8?q?=20add=20argument=20parsing=20to=20howto.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-meta-v2.json | 6 +++--- single-scripts/howto.ts | 27 +++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/script-meta-v2.json b/script-meta-v2.json index c775275..ca965f8 100644 --- a/script-meta-v2.json +++ b/script-meta-v2.json @@ -153,12 +153,12 @@ }, "howto.ts": { "script_name": "howto.ts", - "script_length": 821, - "script_sha256": "184a8887383342c7aa56adf9d68f1ab87e14cabf2461e9445c1dc975cdc6407f", + "script_length": 1225, + "script_sha256": "97b7f0efd97b774c70000a5cb56f9115df0e9473cc2018b0404f7556bdba0e83", "script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/howto.ts", "single_script_file": true, "publish_time": 1775973075081, - "update_time": 1775973075081 + "update_time": 1775973377013 }, "init-cheatsheet.ts": { "script_name": "init-cheatsheet.ts", diff --git a/single-scripts/howto.ts b/single-scripts/howto.ts index 248ce82..353a8b4 100755 --- a/single-scripts/howto.ts +++ b/single-scripts/howto.ts @@ -1,10 +1,29 @@ #!/usr/bin/env runts -- --allow-all -import {log, ProcessBar,} from "https://script.hatter.ink/@67/deno-commons-mod.ts"; +import {parseArgs} from "jsr:@std/cli/parse-args"; +import {exit, log, ProcessBar,} from "https://script.hatter.ink/@67/deno-commons-mod.ts"; import {howto} from "https://script.hatter.ink/@1/deno-ai-mod.ts"; async function main() { - const message = prompt("Input your message: "); + const flags = parseArgs(Deno.args, { + boolean: ["help"], + alias: { + h: "help", + }, + }); + + if (flags.help) { + console.log(`howto.ts + +howto.ts --help - show help +howto.ts 'MESSAGE' - generate command line for MESSAGE +`); + exit(0); + } + + const message = (flags._) + ? flags._.join(" ") + : prompt("Input your message: "); if (!message) { throw new Error("Message is required"); } @@ -21,5 +40,5 @@ main().catch((err) => { process.exit(0); }).then(() => process.exit(0)); -// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260412T135106+08:00.MEQCICWC9h53VEbG8dkDhZRg -// LBcxOktVwEDhnmlQU0MDXiCEAiAB3frJ/GSnacJJ6FXmljy8NmL9kFbqg6hBJUn49QOOYA== +// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260412T135613+08:00.MEUCIQDbJGYgxtAv1d6Vrmyj +// vQDEJGFUuZuH1UQOYQhWRzN69wIgS8tw92nMpF5TLQy/qS4uk7w7d8iY8rmT6DR+V3jg0lM=