+ notmuch_opt_desc_t options[] = {
+ { .opt_bool = &batch, .name = "batch" },
+ { .opt_string = &input_file_name, .name = "input" },
+ { .opt_bool = &remove_all, .name = "remove-all" },
+ { .opt_inherit = notmuch_shared_options },
+ { }
+ };
+
+ opt_index = parse_arguments (argc, argv, options, 1);
+ if (opt_index < 0)
+ return EXIT_FAILURE;
+
+ notmuch_process_shared_options (notmuch, argv[0]);
+
+ if (input_file_name) {
+ batch = true;
+ input = fopen (input_file_name, "r");
+ if (input == NULL) {
+ fprintf (stderr, "Error opening %s for reading: %s\n",
+ input_file_name, strerror (errno));
+ return EXIT_FAILURE;
+ }
+ }
+
+ if (batch) {
+ if (opt_index != argc) {
+ fprintf (stderr, "Can't specify both cmdline and stdin!\n");
+ if (input)
+ fclose (input);
+ return EXIT_FAILURE;
+ }
+ } else {
+ tag_ops = tag_op_list_create (notmuch);
+ if (tag_ops == NULL) {
+ fprintf (stderr, "Out of memory.\n");
+ return EXIT_FAILURE;
+ }