开发者

Tab Based Autocomplete in Console App

I am writing a console based Java application in which the user will be presented a custom command prompts where she can type certain commands, I want to implement an auto complete feature for the app by which while typing the command, if the user presses TAB then the command should complete. The functionality is similar to auto complete in Linux command prompt.

In Java Console App we don't get the control over TAB and a TAB pressed will by default append 8 spaces. I need some trick u开发者_JAVA技巧sing which the TAB doesn't go for rendering and my app can replace the TAB with autocomplete.

Thanks in advance.


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


The picocli Java command line parsing library recently added autocomplete functionality.

You may also like how it enables you to use ANSI colors and styles in the usage help message.

Tab Based Autocomplete in Console App

Disclaimer: I am the author and therefore biased.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜