add bins and alternatives

This commit is contained in:
JOLIMAITRE Matthieu 2024-06-18 03:52:40 +02:00
parent a935bb9893
commit 9f3594e0d3
21 changed files with 210 additions and 10 deletions

View file

@ -0,0 +1,37 @@
#!/bin/env -S deno run -A
import { crayon } from "https://deno.land/x/crayon@3.3.3/mod.ts";
const [filename] = Deno.args;
const args = [filename];
const { stdout } = await new Deno
.Command("strings", { args, stdout: "piped" })
.output();
const strings = new TextDecoder().decode(stdout);
let passed = false;
let rest = strings.split("\n").filter((l) => {
if (l === "IDATx") passed = true;
return !passed;
}).join("\n");
function split_once(text: string, sep: string) {
const [first, ...rest] = text.split(sep);
return [first, rest.join(sep)];
}
let _, prompt, negative, settings;
[_, rest] = split_once(rest, "parameters\n");
[prompt, rest] = split_once(rest, "\nNegative prompt: ");
[negative, rest] = split_once(rest, "\nSteps: ");
[settings, _] = split_once(rest, "\nIDATx");
settings = "Steps: " + settings;
const pairs = settings.split(", ").map((p) => split_once(p, ": "));
for (const [key, value] of pairs) {
console.log(`${crayon.yellow.bold((key + ":").padEnd(12))} ${value}`);
}
console.log(`${crayon.yellow.bold("prompt:")}
${prompt}
${crayon.yellow.bold("negative:")}
${negative}`);