tangled
alpha
login
or
join now
tsiry-sandratraina.com
/
freebsd-up
1
fork
atom
A simple, zero-configuration script to quickly boot FreeBSD ISO images using QEMU
1
fork
atom
overview
issues
pulls
pipelines
Add 'rm' command to remove virtual machines
tsiry-sandratraina.com
4 months ago
14e69489
48b13d8f
+20
2 changed files
expand all
collapse all
unified
split
main.ts
src
subcommands
rm.ts
+6
main.ts
···
4
4
import { createBridgeNetworkIfNeeded } from "./src/network.ts";
5
5
import inspect from "./src/subcommands/inspect.ts";
6
6
import ps from "./src/subcommands/ps.ts";
7
7
+
import rm from "./src/subcommands/rm.ts";
7
8
import start from "./src/subcommands/start.ts";
8
9
import stop from "./src/subcommands/stop.ts";
9
10
import {
···
132
133
.arguments("<vm-name:string>")
133
134
.action(async (_options: unknown, vmName: string) => {
134
135
await inspect(vmName);
136
136
+
})
137
137
+
.command("rm", "Remove a virtual machine")
138
138
+
.arguments("<vm-name:string>")
139
139
+
.action(async (_options: unknown, vmName: string) => {
140
140
+
await rm(vmName);
135
141
})
136
142
.parse(Deno.args);
137
143
}
+14
src/subcommands/rm.ts
···
1
1
+
import { getInstanceState, removeInstanceState } from "../state.ts";
2
2
+
3
3
+
export default async function (name: string) {
4
4
+
const vm = await getInstanceState(name);
5
5
+
if (!vm) {
6
6
+
console.error(
7
7
+
`Virtual machine with name or ID ${name} not found.`,
8
8
+
);
9
9
+
Deno.exit(1);
10
10
+
}
11
11
+
12
12
+
console.log(`Removing virtual machine ${vm.name} (ID: ${vm.id})...`);
13
13
+
await removeInstanceState(name);
14
14
+
}