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: us...@infra.apache.org