Skip to content

Commit

Permalink
Allow both standard output and clipboard in with --ocr
Browse files Browse the repository at this point in the history
  • Loading branch information
xenodium committed Jul 16, 2024
1 parent d066cfd commit cb4dc64
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions Sources/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -715,19 +715,19 @@ func recognizeText(in image: NSImage, useClipboard: Bool, saveToFile outputPath:
let pasteboard = NSPasteboard.general
pasteboard.clearContents()
pasteboard.setString(topCandidate.string, forType: .string)
} else {
if let outputPath = outputPath {
let outputURL = URL(fileURLWithPath: outputPath)
do {
try topCandidate.string.write(to: outputURL, atomically: true, encoding: .utf8)
} catch {
print(String(describing: error))
Darwin.exit(1)
}
} else {
print(topCandidate.string)
}
if let outputPath = outputPath {
let outputURL = URL(fileURLWithPath: outputPath)
do {
try topCandidate.string.write(to: outputURL, atomically: true, encoding: .utf8)
} catch {
print(String(describing: error))
Darwin.exit(1)
}
} else {
print(topCandidate.string)
}

}
}
}
Expand Down

0 comments on commit cb4dc64

Please sign in to comment.