[tracker/wip/carlosg/cli-split] tracker: Add --url argument to "tracker info"



commit fa662d007f60136018865bec34d07861fe01798f
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Jan 6 13:46:49 2020 +0100

    tracker: Add --url argument to "tracker info"
    
    We still default to nie:url and Nepomuk, as there's plenty of advice
    around about just doing "tracker info <uri>". However we don't want
    to fixate on Nepomuk here, so add an --url <url-property> argument
    that allows tweaking that.

 src/tracker/tracker-info.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/src/tracker/tracker-info.c b/src/tracker/tracker-info.c
index 261d09061..17a0bee3a 100644
--- a/src/tracker/tracker-info.c
+++ b/src/tracker/tracker-info.c
@@ -43,6 +43,7 @@ static gboolean full_namespaces;
 static gboolean plain_text_content;
 static gboolean resource_is_iri;
 static gboolean turtle;
+static gchar *url_property;
 
 static GOptionEntry entries[] = {
        { "full-namespaces", 'f', 0, G_OPTION_ARG_NONE, &full_namespaces,
@@ -67,6 +68,10 @@ static GOptionEntry entries[] = {
          N_("Output results as RDF in Turtle format"),
          NULL,
        },
+       { "url", 'u', 0, G_OPTION_ARG_STRING, &url_property,
+         N_("RDF property to treat as URL (eg. “nie:url”)"),
+         NULL,
+       },
        { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames,
          N_("FILE"),
          N_("FILE")},
@@ -274,6 +279,9 @@ info_run (void)
                g_print ("\n");
        }
 
+       if (!url_property)
+               url_property = g_strdup ("nie:url");
+
        for (p = filenames; *p; p++) {
                TrackerSparqlCursor *cursor = NULL;
                GError *error = NULL;
@@ -300,7 +308,7 @@ info_run (void)
 
                if (!resource_is_iri) {
                        /* First check whether there's some entity with nie:url like this */
-                       query = g_strdup_printf ("SELECT ?urn WHERE { ?urn nie:url \"%s\" }", uri);
+                       query = g_strdup_printf ("SELECT ?urn WHERE { ?urn %s \"%s\" }", url_property, uri);
                        cursor = tracker_sparql_connection_query (connection, query, NULL, &error);
                        g_free (query);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]