You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Mike Hummel <mh...@mhus.de> on 2020/02/14 07:29:31 UTC
Re: How to read single character from a Karaf's command
Hi,
you could try
((LineReaderImpl) session.get(".reader")).readCharacter()
Best regards,
Mike
> On 21. Jan 2020, at 17:40, Alex Soto <al...@envieta.com> wrote:
>
> Hello,
>
> I am trying to to write a Karaf Command that can pause its output until the user presses any key, or ‘q’, similar to how Linux `more` command does. So far I have been able to prompt for user input using org.apache.karaf.shell.api.console.Session.readLine, but this requires the user to press the Enter key. I want the user to press the space bar or key `q` (for quit) without having to press the Enter key.
>
> Any hints or pointers on how to accomplish this?
>
>
> Best regards,
> Alex soto
>
>
>
>
Re: How to read single character from a Karaf's command
Posted by Mike Hummel <mh...@mhus.de>.
Hi, sorry for delay...
the source is here https://github.com/mhus/mhus-osgi-tools/blob/master/mhu-osgi-api/src/main/java/de/mhus/osgi/api/karaf/KarafConsole.java
you can have a look in the pom file of the project for dependencies.
Best Regards,
Mike
> On 14. Feb 2020, at 15:13, Alex Soto <al...@envieta.com> wrote:
>
> Thanks Mike,
>
>
> I assume you are referring to this class org.jline.reader.impl.LineReaderImpl from JLine bundle; unfortunately, it is not exported, so I don’t have visibility to use it in my code. This class implements interface org.jline.reader.LineReader, which is visible, but it does not have a readCharacter method. How did you overcome this?
>
> Thanks and best regards,
> Alex soto
>
>
>
>
>> On Feb 14, 2020, at 2:29 AM, Mike Hummel <mh@mhus.de <ma...@mhus.de>> wrote:
>>
>> Hi,
>>
>> you could try
>>
>> ((LineReaderImpl) session.get(".reader")).readCharacter()
>>
>> Best regards,
>> Mike
>>
>>> On 21. Jan 2020, at 17:40, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> wrote:
>>>
>>> Hello,
>>>
>>> I am trying to to write a Karaf Command that can pause its output until the user presses any key, or ‘q’, similar to how Linux `more` command does. So far I have been able to prompt for user input using org.apache.karaf.shell.api.console.Session.readLine, but this requires the user to press the Enter key. I want the user to press the space bar or key `q` (for quit) without having to press the Enter key.
>>>
>>> Any hints or pointers on how to accomplish this?
>>>
>>>
>>> Best regards,
>>> Alex soto
>>>
>>>
>>>
>>>
>>
>
Re: How to read single character from a Karaf's command
Posted by Alex Soto <al...@envieta.com>.
Thanks Mike,
I assume you are referring to this class org.jline.reader.impl.LineReaderImpl from JLine bundle; unfortunately, it is not exported, so I don’t have visibility to use it in my code. This class implements interface org.jline.reader.LineReader, which is visible, but it does not have a readCharacter method. How did you overcome this?
Thanks and best regards,
Alex soto
> On Feb 14, 2020, at 2:29 AM, Mike Hummel <mh...@mhus.de> wrote:
>
> Hi,
>
> you could try
>
> ((LineReaderImpl) session.get(".reader")).readCharacter()
>
> Best regards,
> Mike
>
>> On 21. Jan 2020, at 17:40, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> wrote:
>>
>> Hello,
>>
>> I am trying to to write a Karaf Command that can pause its output until the user presses any key, or ‘q’, similar to how Linux `more` command does. So far I have been able to prompt for user input using org.apache.karaf.shell.api.console.Session.readLine, but this requires the user to press the Enter key. I want the user to press the space bar or key `q` (for quit) without having to press the Enter key.
>>
>> Any hints or pointers on how to accomplish this?
>>
>>
>> Best regards,
>> Alex soto
>>
>>
>>
>>
>