+ if (strcmp (argv[i], "--") == 0) {
+ i++;
+ break;
+ }
+ if (STRNCMP_LITERAL (argv[i], "--format=") == 0) {
+ opt = argv[i] + sizeof ("--format=") - 1;
+ if (strcmp (opt, "text") == 0) {
+ format = &format_text;
+ } else if (strcmp (opt, "json") == 0) {
+ format = &format_json;
+ params.entire_thread = 1;
+ } else if (strcmp (opt, "mbox") == 0) {
+ format = &format_mbox;
+ mbox = 1;
+ } else if (strcmp (opt, "raw") == 0) {
+ format = &format_raw;
+ params.raw = 1;
+ } else {
+ fprintf (stderr, "Invalid value for --format: %s\n", opt);
+ return 1;
+ }
+ format_specified = 1;
+ } else if (STRNCMP_LITERAL (argv[i], "--part=") == 0) {
+ params.part = atoi(argv[i] + sizeof ("--part=") - 1);
+ } else if (STRNCMP_LITERAL (argv[i], "--entire-thread") == 0) {
+ params.entire_thread = 1;
+ } else if ((STRNCMP_LITERAL (argv[i], "--verify") == 0) ||
+ (STRNCMP_LITERAL (argv[i], "--decrypt") == 0)) {
+ if (params.cryptoctx == NULL) {
+ GMimeSession* session = g_object_new(notmuch_gmime_session_get_type(), NULL);
+ if (NULL == (params.cryptoctx = g_mime_gpg_context_new(session, "gpg")))
+ fprintf (stderr, "Failed to construct gpg context.\n");
+ else
+ g_mime_gpg_context_set_always_trust((GMimeGpgContext*)params.cryptoctx, FALSE);
+ g_object_unref (session);
+ session = NULL;
+ }
+ if (STRNCMP_LITERAL (argv[i], "--decrypt") == 0)
+ params.decrypt = 1;
+ } else {
+ fprintf (stderr, "Unrecognized option: %s\n", argv[i]);
+ return 1;
+ }