You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2021/01/21 15:30:58 UTC

[GitHub] [maven-shared-utils] gnodet opened a new pull request #70: [MNG-6915] Add a helper method to get the terminal width

gnodet opened a new pull request #70:
URL: https://github.com/apache/maven-shared-utils/pull/70


   


----------------------------------------------------------------
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.

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



[GitHub] [maven-shared-utils] elharo commented on a change in pull request #70: [MNG-6915] Add a helper method to get the terminal width

Posted by GitBox <gi...@apache.org>.
elharo commented on a change in pull request #70:
URL: https://github.com/apache/maven-shared-utils/pull/70#discussion_r562546705



##########
File path: src/main/java/org/apache/maven/shared/utils/logging/MessageUtils.java
##########
@@ -201,4 +201,21 @@ public void run()
             Runtime.getRuntime().addShutdownHook( shutdownHook );
         }
     }
+
+    /**
+     * Get the terminal width or 0 if the width can not be determined.

Review comment:
       nit: can not --> cannot

##########
File path: src/main/java/org/apache/maven/shared/utils/logging/MessageUtils.java
##########
@@ -201,4 +201,21 @@ public void run()
             Runtime.getRuntime().addShutdownHook( shutdownHook );
         }
     }
+
+    /**
+     * Get the terminal width or 0 if the width can not be determined.
+     *
+     * @return the terminal width
+     */
+    public static int getTerminalWidth()

Review comment:
       This needs a test. 

##########
File path: src/main/java/org/apache/maven/shared/utils/logging/MessageUtils.java
##########
@@ -201,4 +201,21 @@ public void run()
             Runtime.getRuntime().addShutdownHook( shutdownHook );
         }
     }
+
+    /**
+     * Get the terminal width or 0 if the width can not be determined.
+     *
+     * @return the terminal width
+     */
+    public static int getTerminalWidth()
+    {
+        if ( JANSI )
+        {
+            return AnsiConsole.getTerminalWidth();
+        }
+        else
+        {
+            return 0;

Review comment:
       -1 is a more common "I couldn't figure out the correct value" flag in these sorts of methods. 




----------------------------------------------------------------
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.

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



[GitHub] [maven-shared-utils] gnodet commented on a change in pull request #70: [MNG-6915] Add a helper method to get the terminal width

Posted by GitBox <gi...@apache.org>.
gnodet commented on a change in pull request #70:
URL: https://github.com/apache/maven-shared-utils/pull/70#discussion_r563993812



##########
File path: src/main/java/org/apache/maven/shared/utils/logging/MessageUtils.java
##########
@@ -201,4 +201,21 @@ public void run()
             Runtime.getRuntime().addShutdownHook( shutdownHook );
         }
     }
+
+    /**
+     * Get the terminal width or 0 if the width can not be determined.
+     *
+     * @return the terminal width
+     */
+    public static int getTerminalWidth()
+    {
+        if ( JANSI )
+        {
+            return AnsiConsole.getTerminalWidth();
+        }
+        else
+        {
+            return 0;

Review comment:
       Up to you, jansi returns 0 in that case, but I can check and translate it to -1.




----------------------------------------------------------------
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.

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



[GitHub] [maven-shared-utils] elharo commented on pull request #70: [MNG-6915] Add a helper method to get the terminal width

Posted by GitBox <gi...@apache.org>.
elharo commented on pull request #70:
URL: https://github.com/apache/maven-shared-utils/pull/70#issuecomment-821557523


   running through Jenkins now: https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-shared-utils/job/MNG-6915/


-- 
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.

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



[GitHub] [maven-shared-utils] gnodet commented on a change in pull request #70: [MNG-6915] Add a helper method to get the terminal width

Posted by GitBox <gi...@apache.org>.
gnodet commented on a change in pull request #70:
URL: https://github.com/apache/maven-shared-utils/pull/70#discussion_r564009694



##########
File path: src/main/java/org/apache/maven/shared/utils/logging/MessageUtils.java
##########
@@ -201,4 +201,21 @@ public void run()
             Runtime.getRuntime().addShutdownHook( shutdownHook );
         }
     }
+
+    /**
+     * Get the terminal width or 0 if the width can not be determined.
+     *
+     * @return the terminal width
+     */
+    public static int getTerminalWidth()
+    {
+        if ( JANSI )
+        {
+            return AnsiConsole.getTerminalWidth();
+        }
+        else
+        {
+            return 0;

Review comment:
       Fixed.  The related maven PR does not have to be changed since the test is `<= 0`
   https://github.com/apache/maven/pull/434/commits/1cf1487af8081faa55eb8bd9956c8f182f76b4aa#diff-ff39a40ae9303293688fbd2f79ad043c73816772bbd153e51681fdb8c384d085R174-R175




----------------------------------------------------------------
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.

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



[GitHub] [maven-shared-utils] rfscholte commented on a change in pull request #70: [MNG-6915] Add a helper method to get the terminal width

Posted by GitBox <gi...@apache.org>.
rfscholte commented on a change in pull request #70:
URL: https://github.com/apache/maven-shared-utils/pull/70#discussion_r564454311



##########
File path: pom.xml
##########
@@ -70,7 +70,7 @@
     <dependency>
       <groupId>org.fusesource.jansi</groupId>
       <artifactId>jansi</artifactId>
-      <version>2.0.1</version>
+      <version>2.2.0</version>
       <optional>true</optional>

Review comment:
       It must be optional, it is Maven that's responsible to provide it and to decide which features are supported.
   Maven 3.3.9 and earlier would otherwise have mixed output.
   




----------------------------------------------------------------
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.

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



[GitHub] [maven-shared-utils] gnodet commented on a change in pull request #70: [MNG-6915] Add a helper method to get the terminal width

Posted by GitBox <gi...@apache.org>.
gnodet commented on a change in pull request #70:
URL: https://github.com/apache/maven-shared-utils/pull/70#discussion_r564009153



##########
File path: src/main/java/org/apache/maven/shared/utils/logging/MessageUtils.java
##########
@@ -201,4 +201,21 @@ public void run()
             Runtime.getRuntime().addShutdownHook( shutdownHook );
         }
     }
+
+    /**
+     * Get the terminal width or 0 if the width can not be determined.
+     *
+     * @return the terminal width
+     */
+    public static int getTerminalWidth()

Review comment:
       I've added a unit test, but I'm a bit skeptical as it's really tied to Jansi's internal and is mostly about checking that `getTerminalWidth()` returns the value that will be returned by the underlying implementation.




----------------------------------------------------------------
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.

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



[GitHub] [maven-shared-utils] elharo commented on a change in pull request #70: [MNG-6915] Add a helper method to get the terminal width

Posted by GitBox <gi...@apache.org>.
elharo commented on a change in pull request #70:
URL: https://github.com/apache/maven-shared-utils/pull/70#discussion_r564418571



##########
File path: pom.xml
##########
@@ -70,7 +70,7 @@
     <dependency>
       <groupId>org.fusesource.jansi</groupId>
       <artifactId>jansi</artifactId>
-      <version>2.0.1</version>
+      <version>2.2.0</version>
       <optional>true</optional>

Review comment:
       Why is this marked optional instead of simply declaring it? It feels like unnecessary complexity. The model code checks for its presence but the test code doesn't seem to. 




----------------------------------------------------------------
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.

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



[GitHub] [maven-shared-utils] gnodet commented on a change in pull request #70: [MNG-6915] Add a helper method to get the terminal width

Posted by GitBox <gi...@apache.org>.
gnodet commented on a change in pull request #70:
URL: https://github.com/apache/maven-shared-utils/pull/70#discussion_r563991395



##########
File path: src/main/java/org/apache/maven/shared/utils/logging/MessageUtils.java
##########
@@ -201,4 +201,21 @@ public void run()
             Runtime.getRuntime().addShutdownHook( shutdownHook );
         }
     }
+
+    /**
+     * Get the terminal width or 0 if the width can not be determined.
+     *
+     * @return the terminal width
+     */
+    public static int getTerminalWidth()

Review comment:
       There's no way to easily ensure the test is run from inside a terminal. This would always fail when running from an IDE for example.




----------------------------------------------------------------
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.

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



[GitHub] [maven-shared-utils] gnodet commented on pull request #70: [MNG-6915] Add a helper method to get the terminal width

Posted by GitBox <gi...@apache.org>.
gnodet commented on pull request #70:
URL: https://github.com/apache/maven-shared-utils/pull/70#issuecomment-821395747


   @MartinKanters rebased and squashed


-- 
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.

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



[GitHub] [maven-shared-utils] gnodet commented on a change in pull request #70: [MNG-6915] Add a helper method to get the terminal width

Posted by GitBox <gi...@apache.org>.
gnodet commented on a change in pull request #70:
URL: https://github.com/apache/maven-shared-utils/pull/70#discussion_r563991395



##########
File path: src/main/java/org/apache/maven/shared/utils/logging/MessageUtils.java
##########
@@ -201,4 +201,21 @@ public void run()
             Runtime.getRuntime().addShutdownHook( shutdownHook );
         }
     }
+
+    /**
+     * Get the terminal width or 0 if the width can not be determined.
+     *
+     * @return the terminal width
+     */
+    public static int getTerminalWidth()

Review comment:
       There's no way to easily ensure the test is run from inside a terminal. This would always fail when running from an IDE for example.

##########
File path: src/main/java/org/apache/maven/shared/utils/logging/MessageUtils.java
##########
@@ -201,4 +201,21 @@ public void run()
             Runtime.getRuntime().addShutdownHook( shutdownHook );
         }
     }
+
+    /**
+     * Get the terminal width or 0 if the width can not be determined.
+     *
+     * @return the terminal width
+     */
+    public static int getTerminalWidth()
+    {
+        if ( JANSI )
+        {
+            return AnsiConsole.getTerminalWidth();
+        }
+        else
+        {
+            return 0;

Review comment:
       Up to you, jansi returns 0 in that case, but I can check and translate it to -1.

##########
File path: src/main/java/org/apache/maven/shared/utils/logging/MessageUtils.java
##########
@@ -201,4 +201,21 @@ public void run()
             Runtime.getRuntime().addShutdownHook( shutdownHook );
         }
     }
+
+    /**
+     * Get the terminal width or 0 if the width can not be determined.
+     *
+     * @return the terminal width
+     */
+    public static int getTerminalWidth()

Review comment:
       I've added a unit test, but I'm a bit skeptical as it's really tied to Jansi's internal and is mostly about checking that `getTerminalWidth()` returns the value that will be returned by the underlying implementation.

##########
File path: src/main/java/org/apache/maven/shared/utils/logging/MessageUtils.java
##########
@@ -201,4 +201,21 @@ public void run()
             Runtime.getRuntime().addShutdownHook( shutdownHook );
         }
     }
+
+    /**
+     * Get the terminal width or 0 if the width can not be determined.
+     *
+     * @return the terminal width
+     */
+    public static int getTerminalWidth()
+    {
+        if ( JANSI )
+        {
+            return AnsiConsole.getTerminalWidth();
+        }
+        else
+        {
+            return 0;

Review comment:
       Fixed.  The related maven PR does not have to be changed since the test is `<= 0`
   https://github.com/apache/maven/pull/434/commits/1cf1487af8081faa55eb8bd9956c8f182f76b4aa#diff-ff39a40ae9303293688fbd2f79ad043c73816772bbd153e51681fdb8c384d085R174-R175




----------------------------------------------------------------
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.

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



[GitHub] [maven-shared-utils] elharo merged pull request #70: [MNG-6915] Add a helper method to get the terminal width

Posted by GitBox <gi...@apache.org>.
elharo merged pull request #70:
URL: https://github.com/apache/maven-shared-utils/pull/70


   


-- 
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.

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