Skip to content

Commit 0cfd690

Browse files
committed
Add suspended and invalid VM support to vm list
Update prlctl
1 parent 2f8f3cd commit 0cfd690

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let package = Package(
1212
// Dependencies declare other packages that this package depends on.
1313
.package(url: "https://github.com/apple/swift-argument-parser", from: "0.4.0"),
1414
.package(url: "https://github.com/soto-project/soto.git", from: "5.0.0"),
15-
.package(url: "https://github.com/jkmassel/prlctl.git", from: "1.12.0"),
15+
.package(url: "https://github.com/jkmassel/prlctl.git", from: "1.14.0"),
1616
.package(url: "https://github.com/ebraraktas/swift-tqdm.git", from: "0.1.2"),
1717
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
1818
.package(name: "kcpassword", url: "https://github.com/jkmassel/kcpassword-swift.git", from: "1.0.0"),

Sources/hostmgr/commands/vm/VMList.swift

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,53 @@ struct VMListCommand: ParsableCommand {
1919
case .running: try printRunningVMs()
2020
case .stopped: try printStoppedVMs()
2121
case .packaged: try printPackagedVMs()
22-
case .suspended: debugPrint("It's not currently possible to look up suspended VMs")
23-
case .invalid: debugPrint("It's not currently possible to look up invalid VMs")
22+
case .suspended: try printSuspendedVMs()
23+
case .invalid: try printInvalidVMs()
2424
case nil: try printAllVMs()
2525
}
2626
}
2727

2828
private func printAllVMs() throws {
2929
try printRunningVMs()
3030
try printStoppedVMs()
31+
try printPackagedVMs()
32+
try printSuspendedVMs()
33+
try printInvalidVMs()
3134
}
3235

3336
private func printRunningVMs() throws {
3437
try Parallels().lookupRunningVMs().forEach {
35-
print("running\t\($0.name)\t\($0.uuid)\t\($0.ipAddress)")
38+
printStatus(status: .running, vm: $0, ip: $0.ipAddress)
3639
}
3740
}
3841

3942
private func printStoppedVMs() throws {
4043
try Parallels().lookupStoppedVMs().forEach {
41-
print("stopped\t\($0.name)\t\($0.uuid)")
44+
printStatus(status: .stopped, vm: $0)
45+
}
46+
}
47+
48+
private func printSuspendedVMs() throws {
49+
try Parallels().lookupSuspendedVMs().forEach {
50+
printStatus(status: .suspended, vm: $0)
4251
}
4352
}
4453

4554
private func printPackagedVMs() throws {
4655
try Parallels().lookupPackagedVMs().forEach {
47-
print("packaged\t\($0.name)\t\($0.uuid)")
56+
printStatus(status: .packaged, vm: $0)
57+
}
58+
}
59+
60+
private func printInvalidVMs() throws {
61+
try Parallels().lookupInvalidVMs().forEach {
62+
printStatus(status: .invalid, vm: $0)
4863
}
4964
}
65+
66+
private func printStatus(status: VMStatus, vm: VMProtocol, ip: String? = nil) {
67+
print("\(status.rawValue)\t\(vm.name)\t\(vm.uuid)")
68+
}
5069
}
5170

5271
extension VMStatus: ExpressibleByArgument {

0 commit comments

Comments
 (0)