Skip to content

Commit

Permalink
Accept NO_COLOR to disable graying repl response values
Browse files Browse the repository at this point in the history
Closes #44
  • Loading branch information
klange committed Mar 5, 2024
1 parent ef2b18f commit 66d8133
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/kuroko.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
static int enableRline = 1;
static int exitRepl = 0;
static int pasteEnabled = 0;
static int noColor = 0;

KRK_Function(exit) {
FUNCTION_TAKES_NONE();
Expand Down Expand Up @@ -130,7 +131,7 @@ KRK_Function(input) {

static void printResult(FILE * file, KrkValue result) {
struct StringBuilder sb = {0};
if (!krk_pushStringBuilderFormat(&sb, " \033[1;90m=> %R\033[0m\n", result)) {
if (!krk_pushStringBuilderFormat(&sb, noColor ? " => %R\n" : " \033[1;90m=> %R\033[0m\n", result)) {
krk_dumpTraceback();
} else {
fwrite(sb.bytes,1,sb.length,file);
Expand Down Expand Up @@ -898,11 +899,11 @@ int main(int argc, char * argv[]) {

KrkValue result = INTEGER_VAL(0);

char * _KUROKOPATH = getenv("KUROKOPATH");
char * env_KUROKOPATH = getenv("KUROKOPATH");

if (_KUROKOPATH) {
if (env_KUROKOPATH) {
/* Build a path by splitting */
krk_push(OBJECT_VAL(krk_copyString(_KUROKOPATH,strlen(_KUROKOPATH))));
krk_push(OBJECT_VAL(krk_copyString(env_KUROKOPATH,strlen(env_KUROKOPATH))));
krk_push(OBJECT_VAL(S(":")));

/* Split into list */
Expand All @@ -926,6 +927,10 @@ int main(int argc, char * argv[]) {
krk_pop(); /* list */
}

char * env_NO_COLOR = getenv("NO_COLOR");

if (env_NO_COLOR && *env_NO_COLOR) noColor = 1;

/**
* Add general builtins that aren't part of the core VM.
* This is where we provide @c input in particular.
Expand Down

0 comments on commit 66d8133

Please sign in to comment.