mirror of https://github.com/apache/maven.git
[MNG-7080] Add a --color option to simplify color support
This commit is contained in:
parent
39254860d6
commit
f98e632108
|
@ -103,6 +103,8 @@ public class CLIManager
|
|||
|
||||
public static final String NO_TRANSFER_PROGRESS = "ntp";
|
||||
|
||||
public static final String COLOR = "color";
|
||||
|
||||
protected Options options;
|
||||
|
||||
@SuppressWarnings( { "static-access", "checkstyle:linelength" } )
|
||||
|
@ -149,6 +151,8 @@ public class CLIManager
|
|||
options.addOption( Option.builder( "cpu" ).longOpt( "check-plugin-updates" ).desc( "Ineffective, only kept for backward compatibility" ).build() );
|
||||
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() );
|
||||
}
|
||||
|
||||
public CommandLine parse( String[] args )
|
||||
|
|
|
@ -113,6 +113,7 @@ import java.util.StringTokenizer;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.apache.maven.cli.CLIManager.COLOR;
|
||||
import static org.apache.maven.cli.ResolveFile.resolveFile;
|
||||
import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
|
||||
|
||||
|
@ -504,6 +505,7 @@ public class MavenCli
|
|||
|
||||
// LOG COLOR
|
||||
String styleColor = cliRequest.getUserProperties().getProperty( STYLE_COLOR_PROPERTY, "auto" );
|
||||
styleColor = cliRequest.commandLine.getOptionValue( COLOR, styleColor );
|
||||
if ( "always".equals( styleColor ) )
|
||||
{
|
||||
MessageUtils.setColorEnabled( true );
|
||||
|
|
|
@ -46,7 +46,9 @@ public class CLIManagerDocumentationTest
|
|||
{
|
||||
public int compare( Option opt1, Option opt2 )
|
||||
{
|
||||
return opt1.getOpt().compareToIgnoreCase( opt2.getOpt() );
|
||||
String s1 = opt1.getOpt() != null ? opt1.getOpt() : opt1.getLongOpt();
|
||||
String s2 = opt2.getOpt() != null ? opt2.getOpt() : opt2.getLongOpt();
|
||||
return s1.compareToIgnoreCase( s2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue