diff --git a/Sources/tart/Commands/Get.swift b/Sources/tart/Commands/Get.swift new file mode 100644 index 0000000..3f9aafc --- /dev/null +++ b/Sources/tart/Commands/Get.swift @@ -0,0 +1,31 @@ +import ArgumentParser +import Foundation + +struct Get: AsyncParsableCommand { + static var configuration = CommandConfiguration(commandName: "get", abstract: "Get a VM's configuration") + + @Argument(help: "VM name") + var name: String + + func run() async throws { + do { + let vmDir = try VMStorageLocal().open(name) + let vmConfig = try VMConfig(fromURL: vmDir.configURL) + let diskSize = try vmDir.sizeBytes() / 1000 / 1000 / 1000 + + print("CPU\tMemory\tDisk\tDisplay") + + var s = "\(vmConfig.cpuCount)\t" + s += "\(vmConfig.memorySize / 1024 / 1024) MB\t" + s += "\(diskSize) GB\t" + s += "\(vmConfig.display.width)x\(vmConfig.display.height)" + print(s) + + Foundation.exit(0) + } catch { + print(error) + + Foundation.exit(1) + } + } +} diff --git a/Sources/tart/Root.swift b/Sources/tart/Root.swift index 24350e5..86845fd 100644 --- a/Sources/tart/Root.swift +++ b/Sources/tart/Root.swift @@ -20,6 +20,7 @@ struct Root: AsyncParsableCommand { Clone.self, Run.self, Set.self, + Get.self, List.self, Login.self, IP.self,