A convenient CLI tool to quickly spin up DragonflyBSD virtual machines using QEMU with sensible defaults.
at main 32 lines 870 B view raw
1import { Effect, pipe } from "effect"; 2import { getInstanceStateOrFail, removeInstanceState } from "../state.ts"; 3 4const removeVirtualMachine = (name: string) => 5 pipe( 6 getInstanceStateOrFail(name), 7 Effect.flatMap((vm) => { 8 console.log(`Removing virtual machine ${vm.name} (ID: ${vm.id})...`); 9 return removeInstanceState(name); 10 }), 11 ); 12 13export default async function (name: string) { 14 const program = pipe( 15 removeVirtualMachine(name), 16 Effect.catchTags({ 17 InstanceNotFoundError: (_error) => 18 Effect.sync(() => { 19 console.error(`Virtual machine with name or ID ${name} not found.`); 20 Deno.exit(1); 21 }), 22 }), 23 Effect.catchAll((error) => 24 Effect.sync(() => { 25 console.error(`Error: ${String(error)}`); 26 Deno.exit(1); 27 }) 28 ), 29 ); 30 31 await Effect.runPromise(program); 32}