Tab Based Autocomplete in Console App

萝らか妹 提交于 2021-02-07 02:43:07

问题


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 using which the TAB doesn't go for rendering and my app can replace the TAB with autocomplete.

Thanks in advance.


回答1:


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




回答2:


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.

Disclaimer: I am the author and therefore biased.



来源:https://stackoverflow.com/questions/6961271/tab-based-autocomplete-in-console-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!