mirror of
https://github.com/samsonjs/Peekaboo.git
synced 2026-04-27 15:07:41 +00:00
Apply SwiftFormat changes
This commit is contained in:
parent
27f229e802
commit
94c09b1c7a
3 changed files with 26 additions and 28 deletions
|
|
@ -97,32 +97,30 @@ struct ImageCommand: ParsableCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func handleError(_ error: Error) {
|
private func handleError(_ error: Error) {
|
||||||
let captureError: CaptureError
|
let captureError: CaptureError = if let err = error as? CaptureError {
|
||||||
if let err = error as? CaptureError {
|
err
|
||||||
captureError = err
|
|
||||||
} else {
|
} else {
|
||||||
captureError = .unknownError(error.localizedDescription)
|
.unknownError(error.localizedDescription)
|
||||||
}
|
}
|
||||||
|
|
||||||
if jsonOutput {
|
if jsonOutput {
|
||||||
let code: ErrorCode
|
let code: ErrorCode = switch captureError {
|
||||||
switch captureError {
|
|
||||||
case .screenRecordingPermissionDenied:
|
case .screenRecordingPermissionDenied:
|
||||||
code = .PERMISSION_ERROR_SCREEN_RECORDING
|
.PERMISSION_ERROR_SCREEN_RECORDING
|
||||||
case .accessibilityPermissionDenied:
|
case .accessibilityPermissionDenied:
|
||||||
code = .PERMISSION_ERROR_ACCESSIBILITY
|
.PERMISSION_ERROR_ACCESSIBILITY
|
||||||
case .appNotFound:
|
case .appNotFound:
|
||||||
code = .APP_NOT_FOUND
|
.APP_NOT_FOUND
|
||||||
case .windowNotFound:
|
case .windowNotFound:
|
||||||
code = .WINDOW_NOT_FOUND
|
.WINDOW_NOT_FOUND
|
||||||
case .fileWriteError:
|
case .fileWriteError:
|
||||||
code = .FILE_IO_ERROR
|
.FILE_IO_ERROR
|
||||||
case .invalidArgument:
|
case .invalidArgument:
|
||||||
code = .INVALID_ARGUMENT
|
.INVALID_ARGUMENT
|
||||||
case .unknownError:
|
case .unknownError:
|
||||||
code = .UNKNOWN_ERROR
|
.UNKNOWN_ERROR
|
||||||
default:
|
default:
|
||||||
code = .CAPTURE_FAILED
|
.CAPTURE_FAILED
|
||||||
}
|
}
|
||||||
outputError(
|
outputError(
|
||||||
message: captureError.localizedDescription,
|
message: captureError.localizedDescription,
|
||||||
|
|
|
||||||
|
|
@ -144,18 +144,18 @@ enum CaptureError: Error, LocalizedError {
|
||||||
|
|
||||||
var exitCode: Int32 {
|
var exitCode: Int32 {
|
||||||
switch self {
|
switch self {
|
||||||
case .noDisplaysAvailable: return 10
|
case .noDisplaysAvailable: 10
|
||||||
case .screenRecordingPermissionDenied: return 11
|
case .screenRecordingPermissionDenied: 11
|
||||||
case .accessibilityPermissionDenied: return 12
|
case .accessibilityPermissionDenied: 12
|
||||||
case .invalidDisplayID: return 13
|
case .invalidDisplayID: 13
|
||||||
case .captureCreationFailed: return 14
|
case .captureCreationFailed: 14
|
||||||
case .windowNotFound: return 15
|
case .windowNotFound: 15
|
||||||
case .windowCaptureFailed: return 16
|
case .windowCaptureFailed: 16
|
||||||
case .fileWriteError: return 17
|
case .fileWriteError: 17
|
||||||
case .appNotFound: return 18
|
case .appNotFound: 18
|
||||||
case .invalidWindowIndex: return 19
|
case .invalidWindowIndex: 19
|
||||||
case .invalidArgument: return 20
|
case .invalidArgument: 20
|
||||||
case .unknownError: return 1
|
case .unknownError: 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class PermissionsChecker {
|
||||||
// We check by attempting to get shareable content
|
// We check by attempting to get shareable content
|
||||||
let semaphore = DispatchSemaphore(value: 0)
|
let semaphore = DispatchSemaphore(value: 0)
|
||||||
var hasPermission = false
|
var hasPermission = false
|
||||||
|
|
||||||
Task {
|
Task {
|
||||||
do {
|
do {
|
||||||
// This will fail if we don't have screen recording permission
|
// This will fail if we don't have screen recording permission
|
||||||
|
|
@ -21,7 +21,7 @@ class PermissionsChecker {
|
||||||
}
|
}
|
||||||
semaphore.signal()
|
semaphore.signal()
|
||||||
}
|
}
|
||||||
|
|
||||||
semaphore.wait()
|
semaphore.wait()
|
||||||
return hasPermission
|
return hasPermission
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue