You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "michael-o (via GitHub)" <gi...@apache.org> on 2023/09/10 13:29:46 UTC

[GitHub] [maven] michael-o commented on a diff in pull request #1231: MNG-7875 colorize transfer messages

michael-o commented on code in PR #1231:
URL: https://github.com/apache/maven/pull/1231#discussion_r1320770513


##########
maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java:
##########
@@ -214,18 +227,37 @@ public void transferSucceeded(TransferEvent event) {
         FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
 
         StringBuilder message = new StringBuilder();
-        message.append(action).append(' ').append(direction).append(' ').append(resource.getRepositoryId());
-        message.append(": ");
-        message.append(resource.getRepositoryUrl()).append(resource.getResourceName());
-        message.append(" (").append(format.format(contentLength));
+        message.append(action).append(lowOn).append(' ').append(direction).append(' ');
+        message.append(lowOff).append(resource.getRepositoryId());
+        message.append(lowOn).append(": ");
+        message.append(resource.getRepositoryUrl()).append(lowOff);
+        appendResource(message, resource.getResourceName());
+        message.append(lowOn).append(" (").append(format.format(contentLength));
 
         long duration = System.currentTimeMillis() - resource.getTransferStartTime();
         if (duration > 0L) {
             double bytesPerSecond = contentLength / (duration / 1000.0);
             message.append(" at ").append(format.format((long) bytesPerSecond)).append("/s");
         }
 
-        message.append(')');
+        message.append(')').append(lowOff);
         out.println(message.toString());
     }
+
+    private void appendResource(StringBuilder message, String resource) {
+        if (!MessageUtils.isColorEnabled()) {
+            message.append(resource);
+            return;
+        }
+        int filename = resource.lastIndexOf('/');
+        int version = resource.substring(0, filename).lastIndexOf('/');
+        int artifactId = resource.substring(0, version).lastIndexOf('/');

Review Comment:
   Can we fully make this assumption?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org