[#587] Enhance picocli-shell-jline3 example: update RELEASE-NOTES and README

This commit is contained in:
Remko Popma
2019-01-04 06:55:41 +09:00
parent 8347846984
commit 5b5dbbf4b5
3 changed files with 11 additions and 6 deletions

View File

@@ -137,6 +137,7 @@ Support was added for the following environment variables to control enabling AN
## <a name="3.9.0-fixes"></a> Fixed issues
- [#574] Add `picocli-shell-jline3` module. Thanks to [mattirn](https://github.com/mattirn) for the pull request.
- [#587] Enhance `picocli-shell-jline3` example by using JLine's `DefaultParser` to split lines into arguments. Thanks to [mattirn](https://github.com/mattirn) for the pull request.
- [#567] Usage message customization API initial implementation. Thanks to [Christian Helmer](https://github.com/SysLord) for the pull request.
- [#530] Added API for easily customizing the usage help message. Thanks to [stechio](https://github.com/stechio) for raising the request and productive discussions.
- [#569] Facilitate customization of the synopsis: split `Help.detailedSynopsis()` into protected methods.

View File

@@ -44,6 +44,9 @@ import java.util.concurrent.TimeUnit;
import org.jline.reader.Completer;
import org.jline.reader.LineReader;
import org.jline.reader.LineReaderBuilder;
import org.jline.reader.EndOfFileException;
import org.jline.reader.UserInterruptException;
import org.jline.reader.ParsedLine;
import org.jline.reader.impl.DefaultParser;
import org.jline.reader.impl.LineReaderImpl;
import org.jline.terminal.TerminalBuilder;
@@ -143,15 +146,17 @@ public class Example {
// start the shell and process input until the user quits with Ctl-D
String line;
while (true) {
while (true) {
try {
line = reader.readLine(prompt, rightPrompt, (MaskingCallback) null, null);
CommandLine.run(commands, line.split("\\s+"));
ParsedLine pl = reader.getParser().parse(line, 0);
String[] arguments = pl.words().toArray(new String[0]);
CommandLine.run(commands, arguments);
} catch (UserInterruptException e) {
// Ignore
} catch (EndOfFileException e) {
return;
}
}
}
} catch (Throwable t) {
t.printStackTrace();

View File

@@ -114,9 +114,8 @@ public class Example {
try {
line = reader.readLine(prompt, rightPrompt, (MaskingCallback) null, null);
ParsedLine pl = reader.getParser().parse(line, 0);
String[] _args = new String[pl.words().size()];
_args = pl.words().toArray(_args);
CommandLine.run(commands, _args);
String[] arguments = pl.words().toArray(new String[0]);
CommandLine.run(commands, arguments);
} catch (UserInterruptException e) {
// Ignore
} catch (EndOfFileException e) {