Skip to content

Commit

Permalink
Fix scrambled output for PNGs
Browse files Browse the repository at this point in the history
  • Loading branch information
atextor committed Oct 11, 2023
1 parent f3a4538 commit c96bcae
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tools/samm-cli/src/main/java/org/eclipse/esmf/SammCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import java.io.InputStream;
import java.util.Properties;

import org.fusesource.jansi.AnsiConsole;

import org.eclipse.esmf.aspect.AspectCommand;

import org.fusesource.jansi.AnsiConsole;
import picocli.CommandLine;

@CommandLine.Command( name = SammCli.COMMAND_NAME,
Expand All @@ -45,7 +45,8 @@ public SammCli() {
final CommandLine.IExecutionExceptionHandler defaultExecutionExceptionHandler = initialCommandLine.getExecutionExceptionHandler();
commandLine = initialCommandLine.setExecutionExceptionHandler( new CommandLine.IExecutionExceptionHandler() {
@Override
public int handleExecutionException( final Exception exception, final CommandLine commandLine, final CommandLine.ParseResult parseResult )
public int handleExecutionException( final Exception exception, final CommandLine commandLine,
final CommandLine.ParseResult parseResult )
throws Exception {
if ( exception.getClass().getName()
.equals( String.format( "%s.MainClassProcessLauncher$SystemExitCaptured", SammCli.class.getPackageName() ) ) ) {
Expand Down Expand Up @@ -94,6 +95,14 @@ public static void main( final String[] argv ) {
}
}

// Imply disabling color when PNGs are generated, otherwise ANSI escapes scramble binary output
if ( argv.length >= 4
&& argv[argv.length - 4].equals( "aspect" )
&& argv[argv.length - 2].equals( "to" )
&& argv[argv.length - 1].equals( "png" ) ) {
disableColor = true;
}

if ( !disableColor ) {
AnsiConsole.systemInstall();
}
Expand Down

0 comments on commit c96bcae

Please sign in to comment.