- argc--; argv++; /* skip subcommand argument */
-
- /* Array of tagging operations (add or remove), terminated with an
- * empty element. */
- tag_ops = talloc_array (ctx, tag_operation_t, argc + 1);
- if (tag_ops == NULL) {
- fprintf (stderr, "Out of memory.\n");
- return 1;
+ 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 (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;
+ }