Skip to content
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

Interactive option is missing some keystrokes on Windows #2222

Closed
rehand opened this issue Mar 8, 2024 · 7 comments
Closed

Interactive option is missing some keystrokes on Windows #2222

rehand opened this issue Mar 8, 2024 · 7 comments
Labels
theme: integration An issue or change related to integration with other frameworks, shells or operating systems theme: shell An issue or change related to interactive (JLine) applications

Comments

@rehand
Copy link

rehand commented Mar 8, 2024

Hello,
I've the problem that if one command has more than one interactive input (e.g. due to interactive options or using System.console().readLine() in the option) that starting with the second input the first entered character is captured by the console (from jline3) itself, but not by the input reader. This is very annoying and confusing when entering passwords (echo = false) because then you don't notice that the first character is lost.

I've added a demo project which reproduces the issue.

The issue occurs only on Windows, I wasn't able to reproduce it on Linux. It also works on Windows using Ubuntu Bash via WSL2.

My example has two interactive options and it also asks via "System.console().readLine()". For each option I'm typing "test". After entering all 4 options you can see, that jline3 captured 3 times "t", so the missing characters.

prompt> cmd option1 option2
Enter value for option1: test
Enter value for option2: est
Enter value for input1: est
Enter value for input2: est
Option 1: test
Option 2: est
Input 1: est
Input 2: est
prompt> ttt

I'd appreciate any help on this issue. It looks related to 1139

testJline3.zip

@remkop
Copy link
Owner

remkop commented Mar 8, 2024

Is this a picocli issue or a JLine issue?

@rehand
Copy link
Author

rehand commented Mar 8, 2024

Could also be a JLine issue, but in general interactive options are broken when using "picocli-shell-jline3"

@rehand
Copy link
Author

rehand commented Mar 13, 2024

I've tried to recreate the issue with plain JLine3 and it also happens there, but only if System.console() is used for input. When using the lineReader it doesn't happen.

@remkop
Copy link
Owner

remkop commented Mar 14, 2024

I've tried to recreate the issue with plain JLine3 and it also happens there, but only if System.console() is used for input. When using the lineReader it doesn't happen.

The lineReader is a JLine class?

It may be tricky to change picocli to use a JLine class instead of System.console() for interactive options.

@rehand
Copy link
Author

rehand commented Mar 14, 2024

Yes, it's org.jline.reader.LineReader

I'm using now the following workaround:
If line reader is available (through CDI) then I'm using line reader, if not, a fallback to System.console() is implemented.

@remkop remkop added theme: shell An issue or change related to interactive (JLine) applications theme: integration An issue or change related to integration with other frameworks, shells or operating systems labels Apr 15, 2024
@remkop
Copy link
Owner

remkop commented Apr 15, 2024

In your workaround, you stopped using picocli interactive options?

I am wondering if there is anything I can/should do for this issue.
One idea is to update the documentation to tell users that interactive options cannot be combined with JLine3. Or, if there is a workaround, to explain this workaround in the picocli documentation for interactive options. What do you think?

@rehand
Copy link
Author

rehand commented Apr 15, 2024

I do use interactive options but I'm resolving them myself via a mixin and then by using the LineReader from JLine.

I also reported the bug to jline3

@remkop remkop closed this as completed May 3, 2024
@remkop remkop closed this as not planned Won't fix, can't repro, duplicate, stale May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: integration An issue or change related to integration with other frameworks, shells or operating systems theme: shell An issue or change related to interactive (JLine) applications
Projects
None yet
Development

No branches or pull requests

2 participants