mirror of
https://github.com/samsonjs/Peekaboo.git
synced 2026-04-27 15:07:41 +00:00
Apply SwiftFormat changes for release preparation
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
57c277f4da
commit
e85f0c81b8
5 changed files with 93 additions and 90 deletions
|
|
@ -483,19 +483,19 @@ struct ImageCommand: ParsableCommand {
|
|||
}
|
||||
}
|
||||
|
||||
internal func getOutputPath(_ fileName: String) -> String {
|
||||
func getOutputPath(_ fileName: String) -> String {
|
||||
if let basePath = path {
|
||||
return determineOutputPath(basePath: basePath, fileName: fileName)
|
||||
determineOutputPath(basePath: basePath, fileName: fileName)
|
||||
} else {
|
||||
return "/tmp/\(fileName)"
|
||||
"/tmp/\(fileName)"
|
||||
}
|
||||
}
|
||||
|
||||
internal func determineOutputPath(basePath: String, fileName: String) -> String {
|
||||
func determineOutputPath(basePath: String, fileName: String) -> String {
|
||||
// Check if basePath looks like a file (has extension and doesn't end with /)
|
||||
// Exclude special directory cases like "." and ".."
|
||||
let isLikelyFile = basePath.contains(".") && !basePath.hasSuffix("/") &&
|
||||
basePath != "." && basePath != ".."
|
||||
basePath != "." && basePath != ".."
|
||||
|
||||
if isLikelyFile {
|
||||
// Create parent directory if needed
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ struct AppsSubcommand: ParsableCommand {
|
|||
err
|
||||
} else if let appError = error as? ApplicationError {
|
||||
switch appError {
|
||||
case .notFound(let identifier):
|
||||
case let .notFound(identifier):
|
||||
.appNotFound(identifier)
|
||||
case .ambiguous(let identifier, _):
|
||||
case let .ambiguous(identifier, _):
|
||||
.invalidArgument("Ambiguous application identifier: '\(identifier)'")
|
||||
}
|
||||
} else {
|
||||
|
|
@ -151,9 +151,9 @@ struct WindowsSubcommand: ParsableCommand {
|
|||
err
|
||||
} else if let appError = error as? ApplicationError {
|
||||
switch appError {
|
||||
case .notFound(let identifier):
|
||||
case let .notFound(identifier):
|
||||
.appNotFound(identifier)
|
||||
case .ambiguous(let identifier, _):
|
||||
case let .ambiguous(identifier, _):
|
||||
.invalidArgument("Ambiguous application identifier: '\(identifier)'")
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -139,7 +139,8 @@ enum CaptureError: Error, LocalizedError {
|
|||
if let error = underlyingError {
|
||||
let errorString = error.localizedDescription
|
||||
if errorString.lowercased().contains("permission") {
|
||||
message += " Permission denied - check that the directory is writable and the application has necessary permissions."
|
||||
message +=
|
||||
" Permission denied - check that the directory is writable and the application has necessary permissions."
|
||||
} else if errorString.lowercased().contains("no such file") {
|
||||
message += " Directory does not exist - ensure the parent directory exists."
|
||||
} else if errorString.lowercased().contains("no space") {
|
||||
|
|
@ -174,7 +175,7 @@ enum CaptureError: Error, LocalizedError {
|
|||
case .captureCreationFailed: 14
|
||||
case .windowNotFound: 15
|
||||
case .windowCaptureFailed: 16
|
||||
case .fileWriteError(_, _): 17
|
||||
case .fileWriteError: 17
|
||||
case .appNotFound: 18
|
||||
case .invalidWindowIndex: 19
|
||||
case .invalidArgument: 20
|
||||
|
|
|
|||
|
|
@ -304,7 +304,6 @@ struct ImageCommandPathHandlingTests {
|
|||
|
||||
@Test("File vs directory path detection", .tags(.fast))
|
||||
func pathDetection() {
|
||||
|
||||
// Test file-like paths (have extension, no trailing slash)
|
||||
let filePaths = [
|
||||
"/tmp/screenshot.png",
|
||||
|
|
@ -499,7 +498,6 @@ struct ImageCommandPathHandlingTests {
|
|||
|
||||
@Suite("ImageCommand Error Handling Tests", .tags(.imageCapture, .unit))
|
||||
struct ImageCommandErrorHandlingTests {
|
||||
|
||||
@Test("Improved file write error messages", .tags(.fast))
|
||||
func improvedFileWriteErrorMessages() {
|
||||
// Test enhanced error messages with different underlying errors
|
||||
|
|
@ -549,7 +547,9 @@ struct ImageCommandErrorHandlingTests {
|
|||
let noUnderlyingMessage = fileErrorWithoutUnderlying.errorDescription ?? ""
|
||||
|
||||
#expect(noUnderlyingMessage.contains("Failed to write capture file to path: /tmp/test.png."))
|
||||
#expect(noUnderlyingMessage.contains("This may be due to insufficient permissions, missing directory, or disk space issues"))
|
||||
#expect(noUnderlyingMessage
|
||||
.contains("This may be due to insufficient permissions, missing directory, or disk space issues")
|
||||
)
|
||||
}
|
||||
|
||||
@Test("Error message formatting consistency", .tags(.fast))
|
||||
|
|
|
|||
|
|
@ -276,7 +276,9 @@ struct ModelsTests {
|
|||
#expect(CaptureError.windowNotFound.errorDescription == "The specified window could not be found.")
|
||||
#expect(CaptureError.windowCaptureFailed.errorDescription == "Failed to capture the specified window.")
|
||||
let fileError = CaptureError.fileWriteError("/tmp/test.png", nil)
|
||||
#expect(fileError.errorDescription?.starts(with: "Failed to write capture file to path: /tmp/test.png.") == true)
|
||||
#expect(fileError.errorDescription?
|
||||
.starts(with: "Failed to write capture file to path: /tmp/test.png.") == true
|
||||
)
|
||||
#expect(CaptureError.appNotFound("Safari")
|
||||
.errorDescription == "Application with identifier 'Safari' not found or is not running."
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue