Browse Source

Add --quiet option to cli

master
cancel 5 years ago
parent
commit
df82ab8d23
  1. 9
      cli_main.c

9
cli_main.c

@ -13,6 +13,7 @@ static void usage(void) {
" -t <number> Number of timesteps to simulate.\n" " -t <number> Number of timesteps to simulate.\n"
" Must be 0 or a positive integer.\n" " Must be 0 or a positive integer.\n"
" Default: 1\n" " Default: 1\n"
" -q or --quiet Don't print the result to stdout.\n"
" -h or --help Print this message and exit.\n" " -h or --help Print this message and exit.\n"
); );
// clang-format on // clang-format on
@ -20,13 +21,15 @@ static void usage(void) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
static struct option cli_options[] = {{"help", no_argument, 0, 'h'}, static struct option cli_options[] = {{"help", no_argument, 0, 'h'},
{"quiet", no_argument, 0, 'q'},
{NULL, 0, NULL, 0}}; {NULL, 0, NULL, 0}};
char *input_file = NULL; char *input_file = NULL;
int ticks = 1; int ticks = 1;
bool print_output = true;
for (;;) { for (;;) {
int c = getopt_long(argc, argv, "t:h", cli_options, NULL); int c = getopt_long(argc, argv, "t:qh", cli_options, NULL);
if (c == -1) if (c == -1)
break; break;
switch (c) { switch (c) {
@ -40,6 +43,9 @@ int main(int argc, char **argv) {
return 1; return 1;
} }
break; break;
case 'q':
print_output = false;
break;
case 'h': case 'h':
usage(); usage();
return 0; return 0;
@ -110,6 +116,7 @@ int main(int argc, char **argv) {
} }
mbuf_reusable_deinit(&mbuf_r); mbuf_reusable_deinit(&mbuf_r);
oevent_list_deinit(&oevent_list); oevent_list_deinit(&oevent_list);
if (print_output)
field_fput(&field, stdout); field_fput(&field, stdout);
field_deinit(&field); field_deinit(&field);
return 0; return 0;

Loading…
Cancel
Save