mirror of https://github.com/apache/maven.git
[MNG-7180] Make --color option behave more like BSD/GNU grep's --color option
This commit is contained in:
parent
7358b084b1
commit
7b355f7223
|
@ -152,7 +152,7 @@ public class CLIManager
|
|||
options.addOption( Option.builder( "up" ).longOpt( "update-plugins" ).desc( "Ineffective, only kept for backward compatibility" ).build() );
|
||||
options.addOption( Option.builder( "npu" ).longOpt( "no-plugin-updates" ).desc( "Ineffective, only kept for backward compatibility" ).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 )
|
||||
|
|
|
@ -506,18 +506,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 ) )
|
||||
|
|
Loading…
Reference in New Issue