aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorJosh Wolfe <thejoshwolfe@gmail.com>2015-12-01 10:44:30 -0700
committerJosh Wolfe <thejoshwolfe@gmail.com>2015-12-01 10:44:30 -0700
commitab327344b671bff7f874f24691d7e3f19176167c (patch)
treec437760bbc1f7059417b21e37c3d15a42534d4e8 /src/main.cpp
parent9278dbedd5242bf4253da29c0fab36eea9dda61b (diff)
parentdfb6682089ad758b7ba72733778a9aa8c544c164 (diff)
downloadzig-ab327344b671bff7f874f24691d7e3f19176167c.tar.gz
zig-ab327344b671bff7f874f24691d7e3f19176167c.zip
merge conflicts
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index d96cb92e40..f0060c2c1d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -25,6 +25,7 @@ static int usage(const char *arg0) {
" --name [name] override output name\n"
" --output [file] override destination path\n"
" --verbose turn on compiler debug output\n"
+ " --color [auto|off|on] enable or disable colored error messages\n"
, arg0);
return EXIT_FAILURE;
}
@@ -43,6 +44,7 @@ struct Build {
OutType out_type;
const char *out_name;
bool verbose;
+ ErrColor color;
};
static int build(const char *arg0, Build *b) {
@@ -73,6 +75,7 @@ static int build(const char *arg0, Build *b) {
if (b->out_name)
codegen_set_out_name(g, buf_create_from_str(b->out_name));
codegen_set_verbose(g, b->verbose);
+ codegen_set_errmsg_color(g, b->color);
codegen_add_root_code(g, &root_source_name, &root_source_code);
codegen_link(g, b->out_file);
@@ -106,7 +109,9 @@ int main(int argc, char **argv) {
return usage(arg0);
} else {
i += 1;
- if (strcmp(arg, "--output") == 0) {
+ if (i >= argc) {
+ return usage(arg0);
+ } else if (strcmp(arg, "--output") == 0) {
b.out_file = argv[i];
} else if (strcmp(arg, "--export") == 0) {
if (strcmp(argv[i], "exe") == 0) {
@@ -118,6 +123,16 @@ int main(int argc, char **argv) {
} else {
return usage(arg0);
}
+ } else if (strcmp(arg, "--color") == 0) {
+ if (strcmp(argv[i], "auto") == 0) {
+ b.color = ErrColorAuto;
+ } else if (strcmp(argv[i], "on") == 0) {
+ b.color = ErrColorOn;
+ } else if (strcmp(argv[i], "off") == 0) {
+ b.color = ErrColorOff;
+ } else {
+ return usage(arg0);
+ }
} else if (strcmp(arg, "--name") == 0) {
b.out_name = argv[i];
} else {