- if (argc && strcmp (argv[0], "--") != 0) {
- output = fopen (argv[0], "w");
+ char *output_file_name = NULL;
+ int opt_index;
+
+ notmuch_opt_desc_t options[] = {
+ { NOTMUCH_OPT_STRING, &output_file_name, "output", 'o', 0 },
+ { 0, 0, 0, 0, 0 }
+ };
+
+ opt_index = parse_arguments (argc, argv, options, 1);
+
+ if (opt_index < 0) {
+ /* diagnostics already printed */
+ return 1;
+ }
+
+ if (output_file_name) {
+ output = fopen (output_file_name, "w");