🔧 Add no-exec flag and update script metadata in howto.ts
This commit is contained in:
@@ -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=
|
||||
|
||||
Reference in New Issue
Block a user