mirror of
https://github.com/samsonjs/Peekaboo.git
synced 2026-03-25 09:25:47 +00:00
Apply SwiftFormat changes for v1.0.0 release
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
1a2a817822
commit
0bec93e364
14 changed files with 95 additions and 77 deletions
|
|
@ -357,7 +357,8 @@ final class ApplicationFinder: Sendable {
|
|||
// If we filtered out all matches, return the original matches to avoid "not found" errors
|
||||
// But log a warning about this case
|
||||
if filteredMatches.isEmpty && !matches.isEmpty {
|
||||
// Logger.shared.debug("All matches were filtered as helpers, returning original matches to avoid 'not found' error")
|
||||
// Logger.shared.debug("All matches were filtered as helpers, returning original matches to avoid 'not
|
||||
// found' error")
|
||||
return matches
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -164,10 +164,15 @@ struct ImageCommand: AsyncParsableCommand {
|
|||
return savedFiles
|
||||
}
|
||||
|
||||
private func captureAllScreensWithFallback(displays: [CGDirectDisplayID]) async throws(CaptureError) -> [SavedFile] {
|
||||
private func captureAllScreensWithFallback(displays: [CGDirectDisplayID]) async throws(CaptureError)
|
||||
-> [SavedFile] {
|
||||
var savedFiles: [SavedFile] = []
|
||||
for (index, displayID) in displays.enumerated() {
|
||||
let savedFile = try await captureSingleDisplayWithFallback(displayID: displayID, index: index, labelSuffix: "")
|
||||
let savedFile = try await captureSingleDisplayWithFallback(
|
||||
displayID: displayID,
|
||||
index: index,
|
||||
labelSuffix: ""
|
||||
)
|
||||
savedFiles.append(savedFile)
|
||||
}
|
||||
return savedFiles
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import Foundation
|
||||
import AppKit
|
||||
import Foundation
|
||||
|
||||
struct ImageErrorHandler {
|
||||
enum ImageErrorHandler {
|
||||
static func handleError(_ error: Error, jsonOutput: Bool) {
|
||||
let captureError: CaptureError = if let err = error as? CaptureError {
|
||||
err
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import Foundation
|
||||
import CoreGraphics
|
||||
import Foundation
|
||||
import ImageIO
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,17 @@ struct JSONResponse: Codable {
|
|||
let debug_logs: [String]
|
||||
let error: ErrorInfo?
|
||||
|
||||
init(success: Bool, data: Any? = nil, messages: [String]? = nil, debugLogs: [String] = [], error: ErrorInfo? = nil) {
|
||||
init(
|
||||
success: Bool,
|
||||
data: Any? = nil,
|
||||
messages: [String]? = nil,
|
||||
debugLogs: [String] = [],
|
||||
error: ErrorInfo? = nil
|
||||
) {
|
||||
self.success = success
|
||||
self.data = data.map(AnyCodable.init)
|
||||
self.messages = messages
|
||||
self.debug_logs = debugLogs
|
||||
debug_logs = debugLogs
|
||||
self.error = error
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ struct WindowBounds: Codable, Sendable {
|
|||
let height: Int
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case x_coordinate = "x_coordinate"
|
||||
case y_coordinate = "y_coordinate"
|
||||
case x_coordinate
|
||||
case y_coordinate
|
||||
case width
|
||||
case height
|
||||
}
|
||||
|
|
@ -149,7 +149,8 @@ enum CaptureError: Error, LocalizedError, Sendable {
|
|||
if !availableTitles.isEmpty {
|
||||
message += " Available windows: \(availableTitles)."
|
||||
}
|
||||
message += " Note: For URLs, try without the protocol (e.g., 'example.com:8080' instead of 'http://example.com:8080')."
|
||||
message +=
|
||||
" Note: For URLs, try without the protocol (e.g., 'example.com:8080' instead of 'http://example.com:8080')."
|
||||
return message
|
||||
case let .windowCaptureFailed(underlyingError):
|
||||
var message = "Failed to capture the specified window."
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import Foundation
|
|||
|
||||
struct OutputPathResolver: Sendable {
|
||||
static func getOutputPath(basePath: String?, fileName: String, screenIndex: Int? = nil) -> String {
|
||||
if let basePath = basePath {
|
||||
if let basePath {
|
||||
validatePath(basePath)
|
||||
return determineOutputPath(basePath: basePath, fileName: fileName, screenIndex: screenIndex)
|
||||
} else {
|
||||
|
|
@ -11,7 +11,7 @@ struct OutputPathResolver: Sendable {
|
|||
}
|
||||
|
||||
static func getOutputPathWithFallback(basePath: String?, fileName: String) -> String {
|
||||
if let basePath = basePath {
|
||||
if let basePath {
|
||||
validatePath(basePath)
|
||||
return determineOutputPathWithFallback(basePath: basePath, fileName: fileName)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import Foundation
|
||||
import CoreGraphics
|
||||
import Foundation
|
||||
@preconcurrency import ScreenCaptureKit
|
||||
|
||||
struct ScreenCapture: Sendable {
|
||||
|
|
|
|||
|
|
@ -263,7 +263,6 @@ struct ImageCommandTests {
|
|||
#expect(command.screenIndex == index)
|
||||
}
|
||||
|
||||
|
||||
@Test(
|
||||
"Window index boundary values",
|
||||
arguments: [0, 1, 10, 9999]
|
||||
|
|
@ -273,7 +272,6 @@ struct ImageCommandTests {
|
|||
#expect(command.windowIndex == index)
|
||||
}
|
||||
|
||||
|
||||
@Test("Error handling for invalid combinations", .tags(.fast))
|
||||
func invalidCombinations() {
|
||||
// Window capture without app should fail in execution
|
||||
|
|
@ -340,7 +338,11 @@ struct ImageCommandPathHandlingTests {
|
|||
func singleScreenFilePath() {
|
||||
// For single screen, should use exact path
|
||||
let fileName = "screen_1_20250608_120000.png"
|
||||
let result = OutputPathResolver.determineOutputPath(basePath: "/tmp/my-screenshot.png", fileName: fileName, screenIndex: 0)
|
||||
let result = OutputPathResolver.determineOutputPath(
|
||||
basePath: "/tmp/my-screenshot.png",
|
||||
fileName: fileName,
|
||||
screenIndex: 0
|
||||
)
|
||||
|
||||
#expect(result == "/tmp/my-screenshot.png")
|
||||
}
|
||||
|
|
@ -575,7 +577,10 @@ struct ImageCommandErrorHandlingTests {
|
|||
// This test validates the logic without actually creating directories
|
||||
|
||||
let fileName = "screen_1_20250608_120001.png"
|
||||
let result = OutputPathResolver.determineOutputPath(basePath: "/tmp/test-path-creation/file.png", fileName: fileName)
|
||||
let result = OutputPathResolver.determineOutputPath(
|
||||
basePath: "/tmp/test-path-creation/file.png",
|
||||
fileName: fileName
|
||||
)
|
||||
|
||||
// Should return the intended path even if directory creation might fail
|
||||
#expect(result == "/tmp/test-path-creation/file_1_20250608_120001.png")
|
||||
|
|
|
|||
Loading…
Reference in a new issue