@@ -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
5271extension VMStatus : ExpressibleByArgument {
0 commit comments