nicooprat / alfred-ocr

Take a snapshot and recognize text
MIT License
65 stars 7 forks source link

Error, unknown command line argument '-l' #4

Closed mathieutu closed 4 years ago

mathieutu commented 5 years ago

When no lang is provided.

nicooprat commented 5 years ago

Just tried, got the same error. Updated Alfred, and it worked again. Can you try plz?

mathieutu commented 5 years ago

Alfred and Tesseract are at last versions on my side, but it's seems normal for tesseract:

$ tesseract /tmp/ocr_snapshot.png stdout -l
Error, unknown command line argument '-l'

Maybe a condition in the bash script?

nicooprat commented 5 years ago

Right! A PR fixed that: https://github.com/nicooprat/alfred-ocr/pull/2. Can you update your script and try again?

mathieutu commented 5 years ago

Script is up-to-date, but there isn't any check in script 😕

nicooprat commented 5 years ago

I believe the part 2>&1 prevents error from breaking output: tesseract /tmp/ocr_snapshot.png stdout -l {query} 2>&1.

mathieutu commented 5 years ago

No, not at all 😅 I made the 2>&1 part, and it's precisely to redirect error to stdout, and so to message.

I personally can't see any difference before/after the #2 PR 😕. Maybe @dkgrieshammer could explain to use what s.he did ?

dkgrieshammer commented 5 years ago

well the {query} causes an issue if empty, 2>&1 redirects an error but the -l still requres an argument; so basically checking if {query} is empty works as shown below;

export PATH=/usr/local/bin/:$PATH

screencapture -i /tmp/ocr_snapshot.png

if [{query} = ""]; then tesseract /tmp/ocr_snapshot.png stdout 2>&1 else tesseract /tmp/ocr_snapshot.png stdout -l {query} 2>&1 fi

mathieutu commented 5 years ago

I totally agree with this message, but if I download the binary in the PR you made, the script isn't unchanged compared to before the PR.

Maybe did you forgot to do something?

mathieutu commented 5 years ago

As we talk about a binary it's difficult to compare versions, so I think it will be better to see that with #5 solved.

bergmul commented 4 years ago

dkgrieshammer's proposed solution works. Should be included.

bergmul commented 4 years ago

I provided a pull request which includes @dkgrieshammer's proposed solution and also solves #7.

nicooprat commented 4 years ago

Feel free to close the issue if the PR fixed your issue 👍