mirror of https://github.com/apache/maven.git
[MNG-7080] Add a --color option to simplify color support
This commit is contained in:
parent
5d6c6e2537
commit
59c5466c40
|
@ -108,6 +108,8 @@ public class CLIManager
|
|||
|
||||
public static final String NO_TRANSFER_PROGRESS = "ntp";
|
||||
|
||||
public static final String COLOR = "color";
|
||||
|
||||
protected Options options;
|
||||
|
||||
@SuppressWarnings( "checkstyle:linelength" )
|
||||
|
@ -150,6 +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() );
|
||||
}
|
||||
|
||||
public CommandLine parse( String[] args )
|
||||
|
|
|
@ -119,6 +119,7 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import static java.util.Comparator.comparing;
|
||||
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 );
|
||||
|
|
|
@ -44,7 +44,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