diff --git a/Xcodes/Backend/AppState.swift b/Xcodes/Backend/AppState.swift index 884bc87..34a0113 100644 --- a/Xcodes/Backend/AppState.swift +++ b/Xcodes/Backend/AppState.swift @@ -191,6 +191,18 @@ class AppState: ObservableObject { // TODO: } + func launch(id: Xcode.ID) { + guard let installedXcode = Current.files.installedXcodes(Path.root/"Applications").first(where: { $0.version == id }) else { return } + NSWorkspace.shared.openApplication(at: installedXcode.path.url, configuration: .init()) + } + + func copyPath(id: Xcode.ID) { + guard let installedXcode = Current.files.installedXcodes(Path.root/"Applications").first(where: { $0.version == id }) else { return } + NSPasteboard.general.declareTypes([.URL, .string], owner: nil) + NSPasteboard.general.writeObjects([installedXcode.path.url as NSURL]) + NSPasteboard.general.setString(installedXcode.path.string, forType: .string) + } + // MARK: - Private private func updateAllXcodes(_ xcodes: [AvailableXcode]) { diff --git a/Xcodes/Frontend/XcodeList/XcodeListView.swift b/Xcodes/Frontend/XcodeList/XcodeListView.swift index 8fedf1d..24dc9df 100644 --- a/Xcodes/Frontend/XcodeList/XcodeListView.swift +++ b/Xcodes/Frontend/XcodeList/XcodeListView.swift @@ -65,12 +65,19 @@ struct XcodeListView: View { Button(action: { xcode.installed ? appState.xcodeBeingConfirmedForUninstallation = xcode : self.appState.install(id: xcode.id) }) { Text(xcode.installed ? "Uninstall" : "Install") } + Divider() if xcode.installed { + Button(action: { self.appState.select(id: xcode.id) }) { + Text("Select") + } + Button(action: { self.appState.launch(id: xcode.id) }) { + Text("Launch") + } Button(action: { self.appState.reveal(id: xcode.id) }) { Text("Reveal in Finder") } - Button(action: { self.appState.select(id: xcode.id) }) { - Text("Select") + Button(action: { self.appState.copyPath(id: xcode.id) }) { + Text("Copy Path") } } }