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:
Peter Steinberger 2025-06-08 04:37:52 +01:00
parent 57c277f4da
commit e85f0c81b8
5 changed files with 93 additions and 90 deletions

View file

@ -483,15 +483,15 @@ struct ImageCommand: ParsableCommand {
} }
} }
internal func getOutputPath(_ fileName: String) -> String { func getOutputPath(_ fileName: String) -> String {
if let basePath = path { if let basePath = path {
return determineOutputPath(basePath: basePath, fileName: fileName) determineOutputPath(basePath: basePath, fileName: fileName)
} else { } 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 /) // Check if basePath looks like a file (has extension and doesn't end with /)
// Exclude special directory cases like "." and ".." // Exclude special directory cases like "." and ".."
let isLikelyFile = basePath.contains(".") && !basePath.hasSuffix("/") && let isLikelyFile = basePath.contains(".") && !basePath.hasSuffix("/") &&

View file

@ -45,9 +45,9 @@ struct AppsSubcommand: ParsableCommand {
err err
} else if let appError = error as? ApplicationError { } else if let appError = error as? ApplicationError {
switch appError { switch appError {
case .notFound(let identifier): case let .notFound(identifier):
.appNotFound(identifier) .appNotFound(identifier)
case .ambiguous(let identifier, _): case let .ambiguous(identifier, _):
.invalidArgument("Ambiguous application identifier: '\(identifier)'") .invalidArgument("Ambiguous application identifier: '\(identifier)'")
} }
} else { } else {
@ -151,9 +151,9 @@ struct WindowsSubcommand: ParsableCommand {
err err
} else if let appError = error as? ApplicationError { } else if let appError = error as? ApplicationError {
switch appError { switch appError {
case .notFound(let identifier): case let .notFound(identifier):
.appNotFound(identifier) .appNotFound(identifier)
case .ambiguous(let identifier, _): case let .ambiguous(identifier, _):
.invalidArgument("Ambiguous application identifier: '\(identifier)'") .invalidArgument("Ambiguous application identifier: '\(identifier)'")
} }
} else { } else {

View file

@ -139,7 +139,8 @@ enum CaptureError: Error, LocalizedError {
if let error = underlyingError { if let error = underlyingError {
let errorString = error.localizedDescription let errorString = error.localizedDescription
if errorString.lowercased().contains("permission") { 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") { } else if errorString.lowercased().contains("no such file") {
message += " Directory does not exist - ensure the parent directory exists." message += " Directory does not exist - ensure the parent directory exists."
} else if errorString.lowercased().contains("no space") { } else if errorString.lowercased().contains("no space") {
@ -174,7 +175,7 @@ enum CaptureError: Error, LocalizedError {
case .captureCreationFailed: 14 case .captureCreationFailed: 14
case .windowNotFound: 15 case .windowNotFound: 15
case .windowCaptureFailed: 16 case .windowCaptureFailed: 16
case .fileWriteError(_, _): 17 case .fileWriteError: 17
case .appNotFound: 18 case .appNotFound: 18
case .invalidWindowIndex: 19 case .invalidWindowIndex: 19
case .invalidArgument: 20 case .invalidArgument: 20

View file

@ -304,7 +304,6 @@ struct ImageCommandPathHandlingTests {
@Test("File vs directory path detection", .tags(.fast)) @Test("File vs directory path detection", .tags(.fast))
func pathDetection() { func pathDetection() {
// Test file-like paths (have extension, no trailing slash) // Test file-like paths (have extension, no trailing slash)
let filePaths = [ let filePaths = [
"/tmp/screenshot.png", "/tmp/screenshot.png",
@ -499,7 +498,6 @@ struct ImageCommandPathHandlingTests {
@Suite("ImageCommand Error Handling Tests", .tags(.imageCapture, .unit)) @Suite("ImageCommand Error Handling Tests", .tags(.imageCapture, .unit))
struct ImageCommandErrorHandlingTests { struct ImageCommandErrorHandlingTests {
@Test("Improved file write error messages", .tags(.fast)) @Test("Improved file write error messages", .tags(.fast))
func improvedFileWriteErrorMessages() { func improvedFileWriteErrorMessages() {
// Test enhanced error messages with different underlying errors // Test enhanced error messages with different underlying errors
@ -549,7 +547,9 @@ struct ImageCommandErrorHandlingTests {
let noUnderlyingMessage = fileErrorWithoutUnderlying.errorDescription ?? "" let noUnderlyingMessage = fileErrorWithoutUnderlying.errorDescription ?? ""
#expect(noUnderlyingMessage.contains("Failed to write capture file to path: /tmp/test.png.")) #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)) @Test("Error message formatting consistency", .tags(.fast))

View file

@ -276,7 +276,9 @@ struct ModelsTests {
#expect(CaptureError.windowNotFound.errorDescription == "The specified window could not be found.") #expect(CaptureError.windowNotFound.errorDescription == "The specified window could not be found.")
#expect(CaptureError.windowCaptureFailed.errorDescription == "Failed to capture the specified window.") #expect(CaptureError.windowCaptureFailed.errorDescription == "Failed to capture the specified window.")
let fileError = CaptureError.fileWriteError("/tmp/test.png", nil) 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") #expect(CaptureError.appNotFound("Safari")
.errorDescription == "Application with identifier 'Safari' not found or is not running." .errorDescription == "Application with identifier 'Safari' not found or is not running."
) )