Tab Based AutoComplete in Console Application

I am writing a Java console application in which the user will be presented with user command prompts, where she can type certain commands, I want to implement an automatic completion function for an application in which when a command is entered, if the user press TAB, then the command should end. The functionality is similar to completion on the Linux command line.

In the Java Console application, we do not gain control over the TAB, and pressing TAB adds 8 spaces by default. I need a trick with which TAB is not suitable for rendering, and my application can replace TAB with autocomplete.

Thanks in advance.

+7
source share
2 answers

You can try using a library like Java-Readline or jline2 .

+7
source

picocli Recently, an autocomplete function has been added to the Java command parsing library.

You might also like the way it allows you to use ANSI colors and styles in your usage help message.

enter image description here

Disclaimer: I am an author and therefore biased.

0
source

All Articles