so where did jline.ConsoleRunner go?

194 views
Skip to first unread message

René Jansen

unread,
Aug 8, 2019, 11:56:04 AM8/8/19
to jline-users
Hi there jline users.

I hope you are having a good day and please forgive the ignorance and mild discomfort in the tone of my question. I have googled for more than 45 minutes now; I also am hungry.

But ... where did jline.ConsoleRunner go?

I am using jline 1.0, mainly for up-and-down arrowing of command history in diverse cli interpreters/repls that I wrote. I invoke those with 'java jline.ConsoleRunner my.package.class' in an alias or shell script. 

The package is org.jline etc now, seeing the contents of the jar. Jline3 is according to the githhub site a successor to Jline2 which is a successor to Jline1. I casnot find any instruction to accomplish what I did in Jline1 anywhere. I have read the wiki. It is sparse when compared to the increase in jar size.

My main motivation is to do more with colour; the cli's do their own parsing. Also, the website admonishes us to use Jline 3 instead of 1 or 2. And of course we want to be up to date.

Questions:

1) how do I do what I did
2) do I now need to introduce dependencies on this tool in my code?
3) why can't I find architecture change decisions between the major versions of Jline?

I hope someone can point me to the location where all is explained.

best regards,

René Jansen.

Guillaume Nodet

unread,
Aug 11, 2019, 11:38:48 AM8/11/19
to jline...@googlegroups.com
JLine 2 and 3 offer more customizations than JLine 1 did.  In the process of adding features and allowing more user customization, the simpliest way using the ConsoleRunner has not been ported.
The default LineReader can be obtained as shown in https://github.com/jline/jline3/wiki/LineReader
I've tried to quickly port the ConsoleRunner here: https://gist.github.com/gnodet/6863cda58b4e202c111553b359238a6c
I haven't really tested it, but that should give you an idea on how to port things.  Note that if you were using completers in jline1, you'll have to rewrite those too.
  

--
You received this message because you are subscribed to the Google Groups "jline-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jline-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jline-users/30acb538-5a8e-43d5-bfc2-20e7d1a633e9%40googlegroups.com.

René Jansen

unread,
Aug 11, 2019, 12:18:39 PM8/11/19
to jline...@googlegroups.com
Hi Guillaume,

thanks for your answer. I have bitten the bullet and integrated jline3 in my code. I think it is a great piece of work and thank you for providing it.

best regards,

René.

Vedant Chawla

unread,
Sep 8, 2022, 4:15:17 AM9/8/22
to jline-users
Hi  Guillaume,
I want to use this functionality of Jline 1.0 jline.ConsoleRunner.getReader().getDefaultPrompt(). Can you suggest how to do the same in Jline 3.x? 
I want to get the dault prompt.
Thanks.

Guillaume Nodet

unread,
Sep 8, 2022, 4:24:32 AM9/8/22
to jline...@googlegroups.com
In JLine3, the prompt variable is not available at the moment.  Also, there's no concept of "default prompt", as any call to readLine() will use the provided prompt.  What do you need it for ?

Vedant Chawla

unread,
Sep 14, 2022, 7:40:14 AM9/14/22
to jline-users
I used the default prompt earlier to compare it with my own prompt. 
However, I faced another issue regarding ConsoleRunner and LineReader.

The problem with the LineReader or History or Completer is that it does not have a main function and previously ConsoleRunner had a main function and hence we did not have to initialize the reader earlier(automatically filled by the main function earlier) . I was using the jline.ConsoleRunner for the history and autocomplete features. The current jline version 3.21.0 does not have this automatically. What could be a workaround for this? I want to execute the LineReader class in a bash file directly.

Vedant Chawla

unread,
Sep 15, 2022, 6:56:35 AM9/15/22
to jline-users
 Hi  Guillaume,
Do you have any suggestion on the above problem
Thanks.

Guillaume Nodet

unread,
Sep 15, 2022, 7:29:06 AM9/15/22
to jline...@googlegroups.com
You need to implement a main, configure the terminal / reader and loop to execute commands:

Vedant Chawla

unread,
Sep 22, 2022, 1:45:12 AM9/22/22
to jline-users
Hi Guillaume,
Regarding the default prompt.. I need it (setDefaultPrompt/getDefaultPrompt)  because it is being used in the Command Line Interface to set the default prompt which in the case of LineReader(3.21.0) is being read as normal string and used as data which is not desired.
Thanks.

Guillaume Nodet

unread,
Sep 22, 2022, 1:53:43 AM9/22/22
to jline...@googlegroups.com
What do you mean by "is being read as normal string and used as data" ?
The old defaultPrompt was used in case no prompt was given to the readLine call. Now, you simply need to always give it to the LineReader readLine calls instead of passing null.

Vedant Chawla

unread,
Sep 26, 2022, 6:16:08 AM9/26/22
to jline-users
Hi Guillaume,
Tried doing the above part by porting the class ConsoleRunner. In the console output we are getting strange characters ( [?2004l ----- something like this). This is because of the   bracked paste mode being ON. Do you have any idea how we could solve regarding this? This was not coming in Jline 1.0.

Vedant Chawla

unread,
Sep 27, 2022, 1:29:51 AM9/27/22
to jline-users
Hi Guillaume,
Do you have any workarounds for the same?
Thanks.

Guillaume Nodet

unread,
Sep 27, 2022, 2:01:26 AM9/27/22
to jline...@googlegroups.com
If bracketed paste mode doesn't work, just disable it... ?

Vedant Chawla

unread,
Sep 27, 2022, 2:17:03 AM9/27/22
to jline-users
Hi Guillaume,
We have tried doing that and it does not work.(reader.unsetOpt(Option.BRACKETED_PASTE))  We tried this and this does not seem to work for us.
Could you suggest some other way?

Vedant Chawla

unread,
Sep 28, 2022, 1:30:26 AM9/28/22
to jline-users
Hi Guillaume,
We are getting this on our console.(Please see attached picture)
image (2).png
Can we disable this command  terminal.puts(Capability.keypad_xmit) or set the Capability.keypad_xmit to NULL. Similarly for  terminal.puts(Capability.keypad_local); 
Can we set it to NULL. The above code is present in LineReaderImpl.java in Jline 3.21.0.
Thanks.

Reply all
Reply to author
Forward
0 new messages