Skip to content

Commit

Permalink
support NO_COLOR env var to disable ansi color
Browse files Browse the repository at this point in the history
  • Loading branch information
gschueler committed Oct 12, 2023
1 parent 20fccc1 commit 844417e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions rd-cli-tool/src/main/java/org/rundeck/client/tool/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,15 @@ public Rd(final ConfigValues src) {

public boolean isAnsiEnabled() {
String term = getString("TERM", null);
String rd_color = getString("RD_COLOR", null);
return "1".equals(rd_color) ||
(
term != null
&& term.contains("color")
&& !"0".equals(rd_color)
);
String rdColor = getString("RD_COLOR", null);

String noColor = getString("NO_COLOR", null); // https://no-color.org/
boolean noColorFlag = noColor != null && !noColor.isEmpty();

boolean autoEnabled = term != null && term.contains("color");
boolean enabled = "1".equals(rdColor);
boolean disabled = "0".equals(rdColor) || noColorFlag;
return enabled || (autoEnabled && !disabled);
}

@Override
Expand Down

0 comments on commit 844417e

Please sign in to comment.