mirror of
https://github.com/samsonjs/Peekaboo.git
synced 2026-04-24 14:37:39 +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) {
|
||||
let captureError: CaptureError
|
||||
if let err = error as? CaptureError {
|
||||
captureError = err
|
||||
let captureError: CaptureError = if let err = error as? CaptureError {
|
||||
err
|
||||
} else {
|
||||
captureError = .unknownError(error.localizedDescription)
|
||||
.unknownError(error.localizedDescription)
|
||||
}
|
||||
|
||||
if jsonOutput {
|
||||
let code: ErrorCode
|
||||
switch captureError {
|
||||
let code: ErrorCode = switch captureError {
|
||||
case .screenRecordingPermissionDenied:
|
||||
code = .PERMISSION_ERROR_SCREEN_RECORDING
|
||||
.PERMISSION_ERROR_SCREEN_RECORDING
|
||||
case .accessibilityPermissionDenied:
|
||||
code = .PERMISSION_ERROR_ACCESSIBILITY
|
||||
.PERMISSION_ERROR_ACCESSIBILITY
|
||||
case .appNotFound:
|
||||
code = .APP_NOT_FOUND
|
||||
.APP_NOT_FOUND
|
||||
case .windowNotFound:
|
||||
code = .WINDOW_NOT_FOUND
|
||||
.WINDOW_NOT_FOUND
|
||||
case .fileWriteError:
|
||||
code = .FILE_IO_ERROR
|
||||
.FILE_IO_ERROR
|
||||
case .invalidArgument:
|
||||
code = .INVALID_ARGUMENT
|
||||
.INVALID_ARGUMENT
|
||||
case .unknownError:
|
||||
code = .UNKNOWN_ERROR
|
||||
.UNKNOWN_ERROR
|
||||
default:
|
||||
code = .CAPTURE_FAILED
|
||||
.CAPTURE_FAILED
|
||||
}
|
||||
outputError(
|
||||
message: captureError.localizedDescription,
|
||||
|
|
|
|||
|
|
@ -144,18 +144,18 @@ enum CaptureError: Error, LocalizedError {
|
|||
|
||||
var exitCode: Int32 {
|
||||
switch self {
|
||||
case .noDisplaysAvailable: return 10
|
||||
case .screenRecordingPermissionDenied: return 11
|
||||
case .accessibilityPermissionDenied: return 12
|
||||
case .invalidDisplayID: return 13
|
||||
case .captureCreationFailed: return 14
|
||||
case .windowNotFound: return 15
|
||||
case .windowCaptureFailed: return 16
|
||||
case .fileWriteError: return 17
|
||||
case .appNotFound: return 18
|
||||
case .invalidWindowIndex: return 19
|
||||
case .invalidArgument: return 20
|
||||
case .unknownError: return 1
|
||||
case .noDisplaysAvailable: 10
|
||||
case .screenRecordingPermissionDenied: 11
|
||||
case .accessibilityPermissionDenied: 12
|
||||
case .invalidDisplayID: 13
|
||||
case .captureCreationFailed: 14
|
||||
case .windowNotFound: 15
|
||||
case .windowCaptureFailed: 16
|
||||
case .fileWriteError: 17
|
||||
case .appNotFound: 18
|
||||
case .invalidWindowIndex: 19
|
||||
case .invalidArgument: 20
|
||||
case .unknownError: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class PermissionsChecker {
|
|||
// We check by attempting to get shareable content
|
||||
let semaphore = DispatchSemaphore(value: 0)
|
||||
var hasPermission = false
|
||||
|
||||
|
||||
Task {
|
||||
do {
|
||||
// This will fail if we don't have screen recording permission
|
||||
|
|
@ -21,7 +21,7 @@ class PermissionsChecker {
|
|||
}
|
||||
semaphore.signal()
|
||||
}
|
||||
|
||||
|
||||
semaphore.wait()
|
||||
return hasPermission
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue