31 lines
792 B
TypeScript
Executable file
31 lines
792 B
TypeScript
Executable file
#!/bin/env -S deno run -A --unstable
|
|
|
|
import { daemon_send, new_cmd_disable, new_cmd_enable, new_cmd_status } from "./src/lib.ts";
|
|
import { socket_path } from "./src/lib/paths.ts";
|
|
|
|
await main();
|
|
async function main() {
|
|
const [kind, ...rest] = Deno.args;
|
|
|
|
if (kind === "status") {
|
|
const res = await daemon_send(socket_path(), new_cmd_status());
|
|
console.log({ res });
|
|
}
|
|
|
|
if (kind === "enable") {
|
|
const [name] = rest;
|
|
const res = await daemon_send(socket_path(), new_cmd_enable(name));
|
|
console.log({ res });
|
|
}
|
|
|
|
if (kind === "disable") {
|
|
const [name] = rest;
|
|
const res = await daemon_send(socket_path(), new_cmd_disable(name));
|
|
console.log({ res });
|
|
}
|
|
|
|
if (kind === "stop") {
|
|
const res = await daemon_send(socket_path(), new_cmd_status());
|
|
console.log({ res });
|
|
}
|
|
}
|