Browse Source

Change to invoke orca_run and reject bad time args

master
cancel 6 years ago
parent
commit
4bb6966550
  1. 38
      cli_main.c

38
cli_main.c

@ -1,5 +1,6 @@
#include "base.h" #include "base.h"
#include "field.h" #include "field.h"
#include "sim.h"
#include <getopt.h> #include <getopt.h>
int main(int argc, char** argv) { int main(int argc, char** argv) {
@ -16,7 +17,13 @@ int main(int argc, char** argv) {
switch (c) { switch (c) {
case 't': case 't':
ticks = atoi(optarg); ticks = atoi(optarg);
if (ticks == 0 && strcmp(optarg, "0")) {
fprintf(stderr, "Bad time argument %s\n", optarg);
return 1;
}
break; break;
case '?':
return 1;
} }
} }
@ -40,24 +47,27 @@ int main(int argc, char** argv) {
field_deinit(&field); field_deinit(&field);
char const* errstr = "Unknown"; char const* errstr = "Unknown";
switch (fle) { switch (fle) {
case Field_load_error_ok: case Field_load_error_ok:
break; break;
case Field_load_error_cant_open_file: case Field_load_error_cant_open_file:
errstr = "Unable to open file"; errstr = "Unable to open file";
break; break;
case Field_load_error_too_many_columns: case Field_load_error_too_many_columns:
errstr = "Grid file has too many columns"; errstr = "Grid file has too many columns";
break; break;
case Field_load_error_no_rows_read: case Field_load_error_no_rows_read:
errstr = "Grid file has no rows"; errstr = "Grid file has no rows";
break; break;
case Field_load_error_not_a_rectangle: case Field_load_error_not_a_rectangle:
errstr = "Grid file is not a rectangle"; errstr = "Grid file is not a rectangle";
break; break;
} }
fprintf(stderr, "File load error: %s\n", errstr); fprintf(stderr, "File load error: %s\n", errstr);
return 1; return 1;
} }
for (int i = 0; i < ticks; ++i) {
orca_run(&field);
}
field_fput(&field, stdout); field_fput(&field, stdout);
field_deinit(&field); field_deinit(&field);
return 0; return 0;

Loading…
Cancel
Save