Implement Get command (#309)

This commit is contained in:
Evan Burkey 2022-11-09 21:14:14 -08:00 committed by GitHub
parent e600d2f036
commit f37372da28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -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)
}
}
}

View File

@ -20,6 +20,7 @@ struct Root: AsyncParsableCommand {
Clone.self,
Run.self,
Set.self,
Get.self,
List.self,
Login.self,
IP.self,