diff --git a/Sources/tart/Commands/Run.swift b/Sources/tart/Commands/Run.swift index 84e3e28a..6ae08357 100644 --- a/Sources/tart/Commands/Run.swift +++ b/Sources/tart/Commands/Run.swift @@ -11,10 +11,18 @@ var vm: VM? struct IPNotFound: Error { } +func completeVM(_ args: [String]) -> [String] { + if let vms = try? VMStorageLocal().list() { + return vms.map { (name, _) in return name } + } + return [] +} + + struct Run: AsyncParsableCommand { static var configuration = CommandConfiguration(abstract: "Run a VM") - @Argument(help: "VM name") + @Argument(help: "VM name", completion: .custom(completeVM)) var name: String @Flag(help: ArgumentHelp(