Provide smarter output on the client, fixes #77

All events are directly forwarded to the client.  The client is now responsible for ordering them per project and displaying them if needed.  A thread is now started to read the terminal input with support for '+' to display one more line per project, '-' to display one line less, and 'Ctrl+L' to redraw the display which could become messed if the build messages are a bit unusual (this may require a better fix though).
This commit is contained in:
Guillaume Nodet
2020-10-07 13:44:48 +02:00
parent 41869a7115
commit dd32f41580
13 changed files with 305 additions and 156 deletions

View File

@@ -51,6 +51,11 @@
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>

View File

@@ -146,9 +146,11 @@ public abstract class Message {
}
public static class BuildMessage extends Message {
final String projectId;
final String message;
public BuildMessage(String message) {
public BuildMessage(String projectId, String message) {
this.projectId = projectId;
this.message = message;
}
@@ -156,6 +158,10 @@ public abstract class Message {
return message;
}
public String getProjectId() {
return projectId;
}
@Override
public String toString() {
return "BuildMessage{" +
@@ -236,11 +242,13 @@ public abstract class Message {
}
private BuildMessage readBuildMessage(DataInputStream input) throws IOException {
String projectId = readUTF(input);
String message = readUTF(input);
return new BuildMessage(message);
return new BuildMessage(projectId.isEmpty() ? null : projectId, message);
}
private void writeBuildMessage(DataOutputStream output, BuildMessage value) throws IOException {
writeUTF(output, value.projectId != null ? value.projectId : "");
writeUTF(output, value.message);
}