This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch MNG-7180 in repository https://gitbox.apache.org/repos/asf/maven.git
commit a70828c7376dc8d07a2800e035271004ba9222e8 Author: Michael Osipov <[email protected]> AuthorDate: Sat Jul 3 18:28:31 2021 +0200 [MNG-7180] Make --color option behave more like BSD/GNU grep's --color option --- .../src/main/java/org/apache/maven/cli/CLIManager.java | 2 +- .../src/main/java/org/apache/maven/cli/MavenCli.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java index a374615..fec2bda 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java @@ -152,7 +152,7 @@ public class CLIManager options.addOption( Option.builder( LEGACY_LOCAL_REPOSITORY ).longOpt( "legacy-local-repository" ).desc( "Use Maven 2 Legacy Local Repository behaviour, ie no use of _remote.repositories. Can also be activated by using -Dmaven.legacyLocalRepo=true" ).build() ); options.addOption( Option.builder( BUILDER ).longOpt( "builder" ).hasArg().desc( "The id of the build strategy to use" ).build() ); options.addOption( Option.builder( NO_TRANSFER_PROGRESS ).longOpt( "no-transfer-progress" ).desc( "Do not display transfer progress when downloading or uploading" ).build() ); - options.addOption( Option.builder().longOpt( COLOR ).hasArg().desc( "Defines the color mode of the output. Available options are auto/always/never" ).build() ); + options.addOption( Option.builder().longOpt( COLOR ).hasArg().optionalArg( true ).desc( "Defines the color mode of the output. Supported are 'auto', 'always', 'never'." ).build() ); } public CommandLine parse( String[] args ) diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java index 21b939e..496be2e 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java @@ -512,18 +512,18 @@ public class MavenCli // LOG COLOR String styleColor = cliRequest.getUserProperties().getProperty( STYLE_COLOR_PROPERTY, "auto" ); styleColor = cliRequest.commandLine.getOptionValue( COLOR, styleColor ); - if ( "always".equals( styleColor ) ) + if ( "always".equals( styleColor ) || "yes".equals( styleColor ) || "force".equals( styleColor ) ) { MessageUtils.setColorEnabled( true ); } - else if ( "never".equals( styleColor ) ) + else if ( "never".equals( styleColor ) || "no".equals( styleColor ) || "none".equals( styleColor ) ) { MessageUtils.setColorEnabled( false ); } - else if ( !"auto".equals( styleColor ) ) + else if ( !"auto".equals( styleColor ) && !"tty".equals( styleColor ) && !"if-tty".equals( styleColor ) ) { - throw new IllegalArgumentException( "Invalid color configuration option [" + styleColor - + "]. Supported values are (auto|always|never)." ); + throw new IllegalArgumentException( "Invalid color configuration value '" + styleColor + + "'. Supported are 'auto', 'always', 'never'." ); } else if ( cliRequest.commandLine.hasOption( CLIManager.BATCH_MODE ) || cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) )
