NonInteractiveCliktConsole only reads in the first line from an input file
See original GitHub issueCurrently the NonInteractiveCliktConsole
only reads in the first line of any input file passed as the input stream.
This can be fixed by caching the buffered reader like I have below.
class NonInteractiveCliktConsole : CliktConsole {
private val bufferedReader by lazy {
System.`in`.bufferedReader()
}
override fun promptForLine(prompt: String, hideInput: Boolean) = try {
print(prompt, false)
bufferedReader.readLine()
} catch (err: IOException) {
null
}
override fun print(text: String, error: Boolean) {
if (error) {
System.err
} else {
System.out
}.print(text)
}
override val lineSeparator: String get() = System.lineSeparator()
}
I’m using version 1.5.0
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
C# File.ReadAllLines only recognizing the first line [closed]
The Console.ReadLine(); code will used input stream. Therefore, The program will wait till the user input something. Read Below article.
Read more >3 ways for reading user's input from console in Java
The Console class was introduced in Java 1.6, and it has been becoming a preferred way for reading user's input from the command...
Read more >36.1. Interactive and non-interactive shells and scripts
An interactive shell reads commands from user input on a tty. Among other things, such a shell reads startup files on activation, displays...
Read more >Having trouble with the Read-Host cmdlet not actually waiting ...
Having trouble with the Read-Host cmdlet not actually waiting for the user input before moving to the next line in the script.
Read more >tcsh - Invoke a C shell - IBM
login file. In the normal case, the shell begins reading commands from the terminal, prompting with >. The shell repeatedly reads a line...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the reports! This is fixed in 4425fe2, which is part of the 2.0.0 release.
Yeah I just ran the tests myself in the hope of finding the issue, but they passed for me, even when using
stdin.provideText("test\ntest\n")
instead of the line joining.When modifying one of the samples to use the code above, I could reproduce the problem though by running:
or
Before thinking about how to add a test here, maybe let’s see if you can reproduce the problem.