-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
is STDIN.tty? really needed? #4
Comments
I added a commit with a potential solution in a separate branch. There might be a reason for the nil value of input, in which case this commit will probably break stuff. |
In other words, yes, lets use ARGF, but the tty? check should remain (unless there's a better alternative). |
You could argue that being able to “type” a string and then on line termination get a language back is a feature not a bug: if STDIN.tty?
ARGF.each do |input|
puts identifier.run(input)
end
else
puts identifier.run(STDIN.read)
end Will work for all cases:
in the last case it will simply allow you to type something and on pressing return it analyses the language. Do you encounter practical situations where you end up passing “nothing”. Since on empty string (“”) it will not block on STDIN.read we might be trying to solve a problem that is not there?
|
All these cases look fine to me. I think currently just running |
In https://github.com/opener-project/language-identifier/blob/master/lib/opener/language_identifier/cli.rb#L72 a call is being made to see if STDIN.tty?
If true - input is set to nil
If false - input is set to STDIN.read
I don't immediately see the reason for this, so the question is: why?
It seems to be broken now, I get a "length" is not defined for nil error.
Did you consider maybe using ARGF.read so that the LanguageIdentifier works both with STDIN and with filenames?
The text was updated successfully, but these errors were encountered: