don't use field

pull/501/head
Mike Barry 2023-02-25 07:15:04 -05:00
rodzic ef9169a9a6
commit 942b0f06a5
2 zmienionych plików z 10 dodań i 3 usunięć

Wyświetl plik

@ -106,7 +106,7 @@ public class Planetiler {
overallTimer = stats.startStageQuietly("overall");
config = PlanetilerConfig.from(arguments);
if (config.color() != null) {
AnsiColors.NO_COLOR = config.color();
AnsiColors.setUseColors(config.color());
}
tmpDir = arguments.file("tmpdir", "temp directory", Path.of("data", "tmp"));
onlyDownloadSources = arguments.getBoolean("only_download", "download source data then exit", false);

Wyświetl plik

@ -1,9 +1,16 @@
package com.onthegomap.planetiler.util;
import java.util.concurrent.atomic.AtomicBoolean;
/** Utilities for styling terminal output. */
public class AnsiColors {
// Support NO_COLOR env var (https://no-color.org/)
public static boolean NO_COLOR = System.getenv("NO_COLOR") != null && !"\0".equals(System.getenv("NO_COLOR"));
private static final AtomicBoolean useColors =
new AtomicBoolean(System.getenv("NO_COLOR") == null || "\0".equals(System.getenv("NO_COLOR")));
public static void setUseColors(boolean colors) {
useColors.set(colors);
}
private AnsiColors() {}
@ -16,7 +23,7 @@ public class AnsiColors {
private static final String BOLD = "\u001B[1m";
private static String color(String fg, String string) {
return NO_COLOR ? string : (fg + string + COLOR_RESET);
return useColors.get() ? (fg + string + COLOR_RESET) : string;
}
public static String red(String string) {