Skip to content

Commit

Permalink
Disable ANSI formatting when NO_COLOR env variable is set
Browse files Browse the repository at this point in the history
  • Loading branch information
en-milie committed Jan 14, 2022
1 parent 0ed0082 commit 20e7923
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/java/com/endava/cats/StartStopListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.endava.cats;

import io.quarkus.runtime.ShutdownEvent;
import io.quarkus.runtime.StartupEvent;
import org.apache.commons.lang3.StringUtils;
import org.fusesource.jansi.Ansi;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;

@ApplicationScoped
public class StartStopListener {

void onStart(@Observes StartupEvent ev) {
String ansiEnabled = System.getenv().get("NO_COLOR");
Ansi.setEnabled(!StringUtils.isNotEmpty(ansiEnabled));
}

void onStop(@Observes ShutdownEvent ev) {
//ntd
}
}

0 comments on commit 20e7923

Please sign in to comment.