utmctl: add delete command

Resolves #5290
This commit is contained in:
osy
2023-05-29 15:29:08 -07:00
parent 08f9a6b9db
commit 3c2906a313
+18 -1
View File
@@ -24,7 +24,7 @@ struct UTMCtl: ParsableCommand {
static var configuration = CommandConfiguration(
commandName: "utmctl",
abstract: "CLI tool for controlling UTM virtual machines.",
subcommands: [List.self, Status.self, Start.self, Suspend.self, Stop.self, Attach.self, File.self, Exec.self, IPAddress.self, Clone.self]
subcommands: [List.self, Status.self, Start.self, Suspend.self, Stop.self, Attach.self, File.self, Exec.self, IPAddress.self, Clone.self, Delete.self]
)
}
@@ -484,6 +484,23 @@ extension UTMCtl {
}
}
extension UTMCtl {
struct Delete: UTMAPICommand {
static var configuration = CommandConfiguration(
abstract: "Delete a virtual machine (there is no confirmation)."
)
@OptionGroup var environment: EnvironmentOptions
@OptionGroup var identifer: VMIdentifier
func run(with application: UTMScriptingApplication) throws {
let vm = try virtualMachine(forIdentifier: identifer, in: application)
vm.delete!()
}
}
}
extension UTMCtl {
struct VMIdentifier: ParsableArguments {
@Argument(help: "Either the UUID or the complete name of the virtual machine.")