summaryrefslogtreecommitdiff
path: root/source/style/package.d
diff options
context:
space:
mode:
authorShav Kinderlehrer <[email protected]>2023-08-10 11:50:57 -0400
committerShav Kinderlehrer <[email protected]>2023-08-10 11:50:57 -0400
commit49768a38a7662dab13f2e6efa9561fbdcb06d83c (patch)
tree31f3149d749a731a45afd11894bf0b65bdbb7573 /source/style/package.d
parent3ba25af848e9789a9a631590d9a251902ee18440 (diff)
downloadprim-49768a38a7662dab13f2e6efa9561fbdcb06d83c.tar.gz
prim-49768a38a7662dab13f2e6efa9561fbdcb06d83c.zip
Add NO_COLOR supportv0.1.0
Diffstat (limited to 'source/style/package.d')
-rw-r--r--source/style/package.d7
1 files changed, 7 insertions, 0 deletions
diff --git a/source/style/package.d b/source/style/package.d
index 2e5ff7f..1c55a99 100644
--- a/source/style/package.d
+++ b/source/style/package.d
@@ -1,15 +1,22 @@
module style;
import std.conv;
+import core.stdc.stdlib : getenv;
import style.color;
string set(string s, int code) {
+ if (getenv("NO_COLOR"))
+ return s;
+
return ("%{\x1b[" ~ to!string(code) ~ "m%}") ~ s ~ (
"%{\x1b[" ~ to!string((Color.reset + 0)) ~ "m%}");
}
string set(string s, int code, bool close) {
+ if (getenv("NO_COLOR"))
+ return s;
+
return ("%{\x1b[" ~ to!string(code) ~ "m%}") ~ s ~ (close ? (
"%{\x1b[" ~ to!string((Color.reset + 0)) ~ "m%}") : "");
}