feat: add a native CLI launcher for local and YouTube playback

Build .build/terebi beside the app. Parse a single local file or YouTube URL, --url, --, and help; reject invalid commands before GUI launch. Resolve the adjacent app through symlinks and launch through NSWorkspace, reusing its process/window and saved progress.

Launch the app without media before delivering URL events. Raw media argv suppress SwiftUI's initial singleton window. Own warm document and internet Apple events because SwiftUI's default external-event routing closes that window; retain initial Finder document delivery to create it.

Verified actual CLI 0/64/69 exit behavior, PATH/symlink discovery from another directory, cold local/YouTube playback, warm local/YouTube replacement in the same native window/process, resume, Finder-style cold launch, and make all check.
This commit is contained in:
2026-10-11 00:04:37 +02:00
parent 0411064f0c
commit 230949bb95
6 changed files with 204 additions and 3 deletions
+13 -3
View File
@@ -10,8 +10,8 @@ OBJECTS := .build/player.o .build/Output.o
SWIFT_SOURCES := Sources/App/TerebiApp.swift Sources/App/CompactWindow.swift Sources/App/YouTubeResolver.swift Sources/App/PlaybackProgress.swift
APP := .build/terebi.app
.PHONY: all run check check-fixtures check-audio check-window check-youtube check-network check-progress
all: $(APP)/Contents/MacOS/terebi $(APP)/Contents/Info.plist
.PHONY: all run check check-fixtures check-audio check-window check-youtube check-network check-progress check-cli
all: .build/terebi $(APP)/Contents/Info.plist
.build:
mkdir -p $@
@@ -30,13 +30,17 @@ $(APP)/Contents/Info.plist: Resources/Info.plist
mkdir -p $(APP)/Contents
cp $< $@
.build/terebi: Sources/CLI/TerebiCLI.swift Sources/CLI/PlayerCommand.swift Sources/App/YouTubeResolver.swift $(APP)/Contents/MacOS/terebi $(APP)/Contents/Info.plist Makefile
rm -f $@
$(SWIFT) -target $(ARCH)-apple-macosx15.0 -swift-version 6 -parse-as-library -O -g Sources/CLI/TerebiCLI.swift Sources/CLI/PlayerCommand.swift Sources/App/YouTubeResolver.swift -framework AppKit -o $@
run: all
open $(APP)
.build/playback-check: Checks/playback.mm $(OBJECTS) Makefile
$(CXX) $(CXXFLAGS) -fobjc-arc $< $(OBJECTS) $(FF_LIBS) $(FRAMEWORKS) -o $@
check: .build/playback-check check-fixtures check-audio check-window check-youtube check-network check-progress
check: .build/playback-check check-fixtures check-audio check-window check-youtube check-network check-progress check-cli
.build/playback-check .build/fixtures
check-fixtures:
@@ -96,3 +100,9 @@ check-network: .build/network-playback-check check-fixtures
check-progress: .build/playback-progress-check
.build/playback-progress-check
.build/player-command-check: Checks/player-command.swift Sources/CLI/PlayerCommand.swift Sources/App/YouTubeResolver.swift Makefile | .build
$(SWIFT) -target $(ARCH)-apple-macosx15.0 -swift-version 6 -parse-as-library -O -g Checks/player-command.swift Sources/CLI/PlayerCommand.swift Sources/App/YouTubeResolver.swift -framework Foundation -o $@
check-cli: .build/player-command-check
.build/player-command-check