History

Add --quiet option to cli

cancel committed 6 years ago

Commit df82ab81 parent a51f2d41 file · +9 −2Browse files

Unified · Split

cli_main.c+9−2
@@ -13,6 +13,7 @@ static void usage(void) { · 12 unmodified lines
1313 " -t <number> Number of timesteps to simulate.\n"
1414 " Must be 0 or a positive integer.\n"
1515 " Default: 1\n"
16+ " -q or --quiet Don't print the result to stdout.\n"
1617 " -h or --help Print this message and exit.\n"
1718 );
1819 // clang-format on
@@ -20,13 +21,15 @@ static void usage(void) { · 1 unmodified line
2021
2122 int main(int argc, char **argv) {
2223 static struct option cli_options[] = {{"help", no_argument, 0, 'h'},
24+ {"quiet", no_argument, 0, 'q'},
2325 {NULL, 0, NULL, 0}};
2426
2527 char *input_file = NULL;
2628 int ticks = 1;
29+ bool print_output = true;
2730
2831 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);
3033 if (c == -1)
3134 break;
3235 switch (c) {
@@ -40,6 +43,9 @@ int main(int argc, char **argv) { · 7 unmodified lines
4043 return 1;
4144 }
4245 break;
46+ case 'q':
47+ print_output = false;
48+ break;
4349 case 'h':
4450 usage();
4551 return 0;
@@ -110,7 +116,8 @@ int main(int argc, char **argv) { · 64 unmodified lines
110116 }
111117 mbuf_reusable_deinit(&mbuf_r);
112118 oevent_list_deinit(&oevent_list);
113− field_fput(&field, stdout);
119+ if (print_output)
120+ field_fput(&field, stdout);
114121 field_deinit(&field);
115122 return 0;
116123 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t