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