#!/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"; async function main(): Promise { const flags = parseArgs(Deno.args, { boolean: ["help"], }); if (flags.help) { console.log(`init-tsscript.ts - Init TypeScript script file init-tsscript.ts [SCRIPT_NAME] `); exit(0); } const name = (flags._ && flags._.length > 0) ? flags._[0] : prompt("Script name:"); if (!name) { log.error("Script name is required"); return; } let scriptFile = name; if (!name.endsWith(".ts")) { scriptFile = `${name}.ts`; } const scriptName = scriptFile; if (await existsPath("single-scripts/")) { scriptFile = "single-scripts/" + scriptFile; } if (await existsPath(scriptFile)) { log.error(`Script ${scriptFile} already exists`); exit(1); } const script = `#!/usr/bin/env runts -- --allow-all import {parseArgs} from "jsr:@std/cli/parse-args"; import {exit, log, } from "../libraries/deno-commons-mod.ts"; function parseFlags(): any { const flags = parseArgs(Deno.args, { boolean: ["help"], alias: { h: "help", }, }); const helpMessage = \`${scriptName} - DESCRIPTION ----- TODO HELP MESSAGE DETAILS ----- \`; if (flags.help) { console.log(helpMessage); exit(0); } return flags; } async function main(): Promise { const flags = parseFlags(); // TODO code here return; } main().catch((err) => { log.error(err); exit(1); }).then(() => exit(0)); `; await writeStringToFile(scriptFile, script); log.success(`Init ${scriptFile} successfully.`); } main().catch((err) => { log.error(err); exit(1); }).then(() => exit(0)); // @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260416T010643+08:00.MEYCIQCAzfRe5exq023/xi+1 // i2xAdACp+B2Q5b6tVkGpdrvrlgIhANQZPKALwdaRNgG2SkckWZxonnaMwbVCjyjFYmq/FXqb