diff --git a/script-meta-v2.json b/script-meta-v2.json index bf3851f..8594690 100644 --- a/script-meta-v2.json +++ b/script-meta-v2.json @@ -153,12 +153,12 @@ }, "howto.ts": { "script_name": "howto.ts", - "script_length": 2121, - "script_sha256": "0c78b2ca3729ffb4fbe92c46f8bc15e62dd9224670db5cc0fe9efccf29759958", + "script_length": 2337, + "script_sha256": "778267bdb0d5005951090f8e3dc608da507343b06f4c1cc507b9ea797bed64ea", "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": 1775980874679 + "update_time": 1775981177228 }, "init-cheatsheet.ts": { "script_name": "init-cheatsheet.ts", diff --git a/single-scripts/howto.ts b/single-scripts/howto.ts index bd0ea0c..303c336 100755 --- a/single-scripts/howto.ts +++ b/single-scripts/howto.ts @@ -6,9 +6,10 @@ import {howto} from "https://script.hatter.ink/@1/deno-ai-mod.ts"; async function main() { const flags = parseArgs(Deno.args, { - boolean: ["help"], + boolean: ["help", "no-exec"], alias: { h: "help", + N: "no-exec", }, }); @@ -21,6 +22,7 @@ howto.ts 'MESSAGE' - generate command line for MESSAGE exit(0); } + const noExec = flags["no-exec"]; const message = (flags._) ? flags._.join(" ") : prompt("Input your message: "); @@ -34,19 +36,24 @@ howto.ts 'MESSAGE' - generate command line for MESSAGE ); log.success(`AI howto command line message: \n${summary}`); - try { - const commandLine = extractCommand(summary); - console.log( - "Command line: ", - term.auto(`[green][[[${commandLine}]]][/]`), - ); + if (!noExec) { + try { + const commandLine = extractCommand(summary); + console.log( + "Found command line: ", + term.auto(`[green][[[${commandLine}]]][/]`), + ); - if (confirm("Execute this command?")) { - const status = await execCommandShell("sh", ["-c", commandLine]); - exit(status); + if (confirm("Execute this command?")) { + const status = await execCommandShell("sh", [ + "-c", + commandLine, + ]); + exit(status); + } + } catch (e) { + log.error("Extract command line failed", e); } - } catch (e) { - log.error("Extract command line failed", e); } } @@ -72,5 +79,5 @@ main().catch((err) => { process.exit(0); }).then(() => process.exit(0)); -// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260412T160105+08:00.MEQCIGSMGJYgv+Am7EZUBj9N -// B1c1seTE1jc48Z7CZiKn0d23AiAdmw6UTSXRMH/BQKbhuVoFs6GiBo783QxnCXYT4TWf8A== +// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260412T160614+08:00.MEUCIEasEUKkR/P0ESG/IpIB +// 9turT2yM/EoOpSEwQdlz277qAiEAxCYPwvP563coKn1Ov3wI1icQR3Tesg2Hta0tdIn8f+8=