kopia lustrzana https://github.com/onthegomap/planetiler
don't use field
rodzic
ef9169a9a6
commit
942b0f06a5
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
Ładowanie…
Reference in New Issue