mirror of https://github.com/cirruslabs/tart.git
Implement Get command (#309)
This commit is contained in:
parent
e600d2f036
commit
f37372da28
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20,6 +20,7 @@ struct Root: AsyncParsableCommand {
|
|||
Clone.self,
|
||||
Run.self,
|
||||
Set.self,
|
||||
Get.self,
|
||||
List.self,
|
||||
Login.self,
|
||||
IP.self,
|
||||
|
|
|
|||
Loading…
Reference in New Issue