aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/cli.ts22
1 files changed, 20 insertions, 2 deletions
diff --git a/scripts/cli.ts b/scripts/cli.ts
index be7a81b..bbb9b4e 100644
--- a/scripts/cli.ts
+++ b/scripts/cli.ts
@@ -3,19 +3,30 @@ const ws = new WebSocket(Deno.args[0])
function do_stuff() {
-
switch (Deno.args[1]) {
case "enqueue":
if (Deno.args.length >= 4)
ws.send(JSON.stringify({ t: "metadata", key: Deno.args[2], data: JSON.parse(Deno.args[3]) }))
ws.send(JSON.stringify({ t: "enqueue", key: Deno.args[2], ignore_complete: true }))
break;
+ case "retry_all":
+ ws.send(JSON.stringify({
+ t: "query",
+ state: "complete",
+ data: { failed: null },
+ cookie: "for_enqueue"
+ }))
+ return;
case "save":
break;
default:
break
}
ws.send(JSON.stringify({ t: "save" }))
+ exit()
+}
+function exit() {
+ setTimeout(() => Deno.exit(0), 200) // not sure if websockets are flushed since they're non-blocking
}
ws.onerror = () => console.error("ws error")
@@ -24,11 +35,18 @@ ws.onopen = () => {
console.log("ws open");
ws.send(JSON.stringify({ t: "register", name: "cli", task_kinds: [] }))
do_stuff()
- setTimeout(() => Deno.exit(0), 200) // not sure if websockets are flushed since they're non-blocking
}
ws.onmessage = ev => {
if (typeof ev.data != "string") return
const p = JSON.parse(ev.data)
if (p.t == "config") return
if (p.t == "error") console.error(`error: ${p.message}`);
+ if (p.t == "query_response" && p.cookie == "for_enqueue") {
+ for (const key of p.keys) {
+ ws.send(JSON.stringify({ t: "metadata", key, data: { failed: null } }))
+ ws.send(JSON.stringify({ t: "enqueue", key, ignore_complete: true }))
+ }
+ ws.send(JSON.stringify({ t: "save" }))
+ exit()
+ }
}