英文:
How to prepend String on each line by jline3?
问题
我想要应用程序在每一行上打印出其名称,类似于(shell >
):
shell > --param1 value1 --param2 value2
是否可以通过jline3实现?
英文:
I want app to print on each line its name like (shell >
):
shell > --param1 value1 --param2 value2
Is it possible to implement it by jline3?
答案1
得分: 0
你可以使用 jline3-terminal 完成这个操作。
它支持 'jansi' 和 'jna'。两者的工作方式几乎相同,但 jansi 比 jna 轻量一些。而 jna 则更通用。
你可以按照文档 <a href="https://github.com/jline/jline3">这里</a> 和终端文档 <a href="https://github.com/jline/jline3/wiki/Terminals">这里</a> 进行操作。
最好使用 Maven 项目开始,并按照文档进行操作。
如果有其他问题,请告诉我。
英文:
You can do this using jline3-terminal.
It has support for 'jansi' and 'jna'. Both work near same, but jansi is a bit light weight than jna. Whereas jna is more generic.
You can follow documentation <a href="https://github.com/jline/jline3">here</a> and the also the terminal documentation <a href="https://github.com/jline/jline3/wiki/Terminals">here</a>.
Prefer maven project to start with and go ahead with documentation.
Let me know for anything else.
答案2
得分: 0
See JLine readLine() javadoc. Add command prompt (shell >
) to your CLI app call readLine
method as
lineReader.readLine("shell > ", null, null);
If you want to add a buffer, also set the default value for the user to edit, call the readLine
method as
lineReader.readLine("shell > ", null, "--param1 value1 --param2 value2");
英文:
See JLine readLine() javadoc. Add command prompt (shell >
) to your CLI app call readLine
method as
lineReader.readLine("shell > ", null, null);
If you want to add buffer also the default value for user to edit call readLine
method as
lineReader.readLine("shell > ", null, "--param1 value1 --param2 value2");
专注分享java语言的经验与见解,让所有开发者获益!
评论