How to prepend String on each line by jline3?

174 Views Asked by At

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?

2

There are 2 best solutions below

1
On

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 here and the also the terminal documentation here.

Prefer maven project to start with and go ahead with documentation.

Let me know for anything else.

0
On

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");