Unified · Split
| @@ -13,6 +13,7 @@ static void usage(void) { · 12 unmodified lines | ||
| 13 | 13 | " -t <number> Number of timesteps to simulate.\n" |
| 14 | 14 | " Must be 0 or a positive integer.\n" |
| 15 | 15 | " Default: 1\n" |
| 16 | + " -q or --quiet Don't print the result to stdout.\n" | |
| 16 | 17 | " -h or --help Print this message and exit.\n" |
| 17 | 18 | ); |
| 18 | 19 | // clang-format on |
| @@ -20,13 +21,15 @@ static void usage(void) { · 1 unmodified line | ||
| 20 | 21 | |
| 21 | 22 | int main(int argc, char **argv) { |
| 22 | 23 | static struct option cli_options[] = {{"help", no_argument, 0, 'h'}, |
| 24 | + {"quiet", no_argument, 0, 'q'}, | |
| 23 | 25 | {NULL, 0, NULL, 0}}; |
| 24 | 26 | |
| 25 | 27 | char *input_file = NULL; |
| 26 | 28 | int ticks = 1; |
| 29 | + bool print_output = true; | |
| 27 | 30 | |
| 28 | 31 | for (;;) { |
| 29 | − int c = getopt_long(argc, argv, "t:h", cli_options, NULL); | |
| 32 | + int c = getopt_long(argc, argv, "t:qh", cli_options, NULL); | |
| 30 | 33 | if (c == -1) |
| 31 | 34 | break; |
| 32 | 35 | switch (c) { |
| @@ -40,6 +43,9 @@ int main(int argc, char **argv) { · 7 unmodified lines | ||
| 40 | 43 | return 1; |
| 41 | 44 | } |
| 42 | 45 | break; |
| 46 | + case 'q': | |
| 47 | + print_output = false; | |
| 48 | + break; | |
| 43 | 49 | case 'h': |
| 44 | 50 | usage(); |
| 45 | 51 | return 0; |
| @@ -110,7 +116,8 @@ int main(int argc, char **argv) { · 64 unmodified lines | ||
| 110 | 116 | } |
| 111 | 117 | mbuf_reusable_deinit(&mbuf_r); |
| 112 | 118 | oevent_list_deinit(&oevent_list); |
| 113 | − field_fput(&field, stdout); | |
| 119 | + if (print_output) | |
| 120 | + field_fput(&field, stdout); | |
| 114 | 121 | field_deinit(&field); |
| 115 | 122 | return 0; |
| 116 | 123 | } |