summaryrefslogtreecommitdiff
path: root/OCRImage/main.swift
diff options
context:
space:
mode:
authordianshi <dianshi@main.lv>2021-03-25 07:42:42 +0000
committerdianshi <dianshi@main.lv>2021-03-25 07:42:42 +0000
commit14e11dda03e022842135fd0ed5e7900d0c3e838b (patch)
tree43d0614bf7d31320862594f3b50152f16a2168f6 /OCRImage/main.swift
parent937d19d5b65867ede7191e3b5e41fd4d04565c48 (diff)
downloadOCRImage-14e11dda03e022842135fd0ed5e7900d0c3e838b.tar.gz
OCRImage-14e11dda03e022842135fd0ed5e7900d0c3e838b.zip
input file parameter if not set then trow error
Diffstat (limited to 'OCRImage/main.swift')
-rw-r--r--OCRImage/main.swift17
1 files changed, 14 insertions, 3 deletions
diff --git a/OCRImage/main.swift b/OCRImage/main.swift
index 79d5b4b..cd3fafd 100644
--- a/OCRImage/main.swift
+++ b/OCRImage/main.swift
@@ -101,7 +101,7 @@ if #available(macOS 10.15,*) {} else {
struct OCROptions : ParsableArguments {
@Option(help:"Input file for OCR")
- var inputFile:String = "/Projects/OCRImage/ExampleInput/sample.png"
+ var inputFile:String?
@Flag(name: .shortAndLong, help:"Show extra debugion info")
var debug=false
@@ -118,15 +118,26 @@ if options.version {
exit(0)
}
+//exit if input-file isnot set
+//if nil == options.inputFile {
+// print("Set --input-file command argument to image")
+// exit(0)
+//}
+guard let inputFile = options.inputFile else {
+ print("ERROR: Set --input-file command argument to image")
+ exit(0)
+}
+
+
+print("OCR Input file: \(inputFile)")
-print("OCR Input file: \(options.inputFile)")
//Try to open file from URL
var fm = FileManager.default.homeDirectoryForCurrentUser
//let fm = FileManager.default
print(fm)
-let path:String = options.inputFile
+let path:String = inputFile
fm.appendPathComponent(path)
let ocrImageUrl = fm.absoluteURL
print(fm)