--- trunk/main.c 2008/05/31 07:38:46 107 +++ trunk/main.c 2008/10/13 17:51:29 311 @@ -23,11 +23,15 @@ #include #include +#include "global.h" #include "instrument.h" #include "instrument-js.h" #include "resource-manager.h" #include "util.h" +const char * jscoverage_encoding = "ISO-8859-1"; +bool jscoverage_highlight = true; + int main(int argc, char ** argv) { int verbose = 0; @@ -49,16 +53,18 @@ exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-V") == 0 || strcmp(argv[i], "--version") == 0) { - printf("jscoverage %s\n", VERSION); - exit(EXIT_SUCCESS); + version(); } else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) { verbose = 1; } + else if (strcmp(argv[i], "--no-highlight") == 0) { + jscoverage_highlight = false; + } else if (strcmp(argv[i], "--no-instrument") == 0) { i++; if (i == argc) { - fatal("--no-instrument: option requires an argument"); + fatal_command_line("--no-instrument: option requires an argument"); } no_instrument[num_no_instrument] = argv[i]; num_no_instrument++; @@ -70,7 +76,7 @@ else if (strcmp(argv[i], "--exclude") == 0) { i++; if (i == argc) { - fatal("--exclude: option requires an argument"); + fatal_command_line("--exclude: option requires an argument"); } exclude[num_exclude] = argv[i]; num_exclude++; @@ -79,8 +85,18 @@ exclude[num_exclude] = argv[i] + 10; num_exclude++; } + else if (strcmp(argv[i], "--encoding") == 0) { + i++; + if (i == argc) { + fatal_command_line("--encoding: option requires an argument"); + } + jscoverage_encoding = argv[i]; + } + else if (strncmp(argv[i], "--encoding=", 11) == 0) { + jscoverage_encoding = argv[i] + 11; + } else if (strncmp(argv[i], "-", 1) == 0) { - fatal("unrecognized option `%s'", argv[i]); + fatal_command_line("unrecognized option `%s'", argv[i]); } else if (source == NULL) { source = argv[i]; @@ -89,12 +105,12 @@ destination = argv[i]; } else { - fatal("too many arguments"); + fatal_command_line("too many arguments"); } } if (source == NULL || destination == NULL) { - fatal("missing argument"); + fatal_command_line("missing argument"); } source = make_canonical_path(source);