Update: CLI support

This commit is contained in:
Hariharan Mudaliar 2026-04-10 15:17:46 +05:30
commit f9fe2e363d
No known key found for this signature in database
GPG key ID: 025583EB0BE5640E
5 changed files with 29860 additions and 29801 deletions

View file

@ -154,6 +154,29 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidBecomeActive(_ notification: Notification) {
installTopMenuItemsIfNeeded()
}
func application(_ application: NSApplication, open urls: [URL]) {
_ = handleIncomingShelfURLs(urls)
}
func application(_ sender: NSApplication, openFile filename: String) -> Bool {
handleIncomingShelfURLs([URL(fileURLWithPath: filename)])
}
private func handleIncomingShelfURLs(_ urls: [URL]) -> Bool {
let fileURLs = urls.filter(\.isFileURL)
guard !fileURLs.isEmpty else { return false }
Task { @MainActor [weak self] in
let items = await ShelfDropService.items(from: fileURLs)
guard !items.isEmpty else { return }
ShelfStateViewModel.shared.add(items)
self?.coordinator.currentView = .shelf
}
return true
}
/// Setup observers for music player state changes to restart AudioTap capture
private func setupAudioTapMusicObservers() {

File diff suppressed because it is too large Load diff

View file

@ -36,6 +36,26 @@ struct ShelfDropService {
return results
}
static func items(from fileURLs: [URL]) async -> [ShelfItem] {
var results: [ShelfItem] = []
let fileManager = FileManager.default
for fileURL in fileURLs {
let resolvedURL = fileURL.standardizedFileURL
guard resolvedURL.isFileURL else { continue }
guard fileManager.fileExists(atPath: resolvedURL.path) else {
NSLog("⚠️ Ignoring non-existent file URL: \(resolvedURL.path)")
continue
}
if let bookmark = createBookmark(for: resolvedURL) {
results.append(await ShelfItem(kind: .file(bookmark: bookmark), isTemporary: false))
}
}
return results
}
private static func processProvider(_ provider: NSItemProvider) async -> ShelfItem? {
if let actualFileURL = await provider.extractFileURL() {
@ -81,4 +101,3 @@ struct ShelfDropService {
return (try? Bookmark(url: url))?.data
}
}