better command line parsing

fix compilation problem
This commit is contained in:
Enno Rehling 2012-05-22 14:53:46 -07:00
parent ecac1adb1b
commit e2a6bbbb72
1 changed files with 22 additions and 4 deletions

View File

@ -91,22 +91,22 @@ static int parse_args(int argc, char **argv, int *exitcode)
} else { } else {
return usage(argv[0], argv[i]); return usage(argv[0], argv[i]);
} }
} else } else {
switch (argv[i][1]) { switch (argv[i][1]) {
case 'C': case 'C':
entry_point = NULL; entry_point = NULL;
break; break;
case 'e': case 'e':
entry_point = argv[++i]; entry_point = argv[i][2] ? argv[i]+2 : argv[++i];
break; break;
case 't': case 't':
turn = atoi(argv[++i]); turn = atoi(argv[i][2] ? argv[i]+2 : argv[++i]);
break; break;
case 'q': case 'q':
verbosity = 0; verbosity = 0;
break; break;
case 'v': case 'v':
verbosity = atoi(argv[++i]); verbosity = atoi(argv[i][2] ? argv[i]+2 : argv[++i]);
break; break;
case 'h': case 'h':
usage(argv[0], NULL); usage(argv[0], NULL);
@ -117,7 +117,25 @@ static int parse_args(int argc, char **argv, int *exitcode)
return 1; return 1;
} }
} }
}
switch (verbosity) {
case 0:
log_stderr = 0;
break;
case 1:
log_stderr = LOG_CPERROR;
break;
case 2:
log_stderr = LOG_CPERROR|LOG_CPWARNING;
break;
case 3:
log_stderr = LOG_CPERROR|LOG_CPWARNING|LOG_CPDEBUG;
break;
default:
log_stderr = LOG_CPERROR|LOG_CPWARNING|LOG_CPDEBUG|LOG_CPINFO;
break;
}
if (run_tests) { if (run_tests) {
*exitcode = RunAllTests(); *exitcode = RunAllTests();
return 1; return 1;