+ if (argc > 0) {
+ if ((query_str = query_string_from_args (ctx, argc, argv)) == NULL) {
+ fprintf (stderr, "Out of memory.\n");
+ goto error;
+ }
+
+ if (*query_str == '\0') {
+ fprintf (stderr, "Error: Invalid search string.\n");
+ goto error;
+ }
+
+ if ((query = notmuch_query_create (db, query_str)) == NULL) {
+ fprintf (stderr, "Out of memory\n");
+ goto error;
+ }
+
+
+ msgs = notmuch_query_search_messages (query);
+ if ((tags = notmuch_messages_collect_tags (msgs)) == NULL) goto error;
+ } else {
+ if ((tags = notmuch_database_get_all_tags (db)) == NULL) {
+ fprintf (stderr, "Error while getting tags from the database.\n");
+ goto error;
+ }
+ }
+
+ print_tags (tags);