[tracker] Improve tracker-{info|import|stats} according to man pages



commit fee7f2d6efc549e886d4e9fb74d30a18ad600beb
Author: Martyn Russell <martyn imendio com>
Date:   Wed Jul 8 18:21:45 2009 +0100

    Improve tracker-{info|import|stats} according to man pages

 src/tracker-extract/tracker-extract.c |    6 +-
 src/tracker-extract/tracker-main.c    |   14 ++--
 src/tracker-utils/tracker-import.c    |   55 ++++++++++-------
 src/tracker-utils/tracker-info.c      |  106 ++++++++++++++++++---------------
 src/tracker-utils/tracker-stats.c     |    2 +-
 5 files changed, 100 insertions(+), 83 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index f21feeb..66ab58e 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -41,7 +41,7 @@
 
 #define TRACKER_EXTRACT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_EXTRACT, TrackerExtractPrivate))
 
-extern gboolean debug_mode;
+extern gboolean debug;
 
 typedef struct {
 	GArray *specific_extractors;
@@ -431,7 +431,7 @@ tracker_extract_get_metadata (TrackerExtract	     *object,
 				    "  Resetting shutdown timeout");
 	
 	tracker_main_quit_timeout_reset ();
-	if (!debug_mode) {
+	if (!debug) {
 		alarm (MAX_EXTRACT_TIME);
 	}
 
@@ -453,7 +453,7 @@ tracker_extract_get_metadata (TrackerExtract	     *object,
 		g_error_free (actual_error);
 	}
 
-	if (!debug_mode) {
+	if (!debug) {
 		/* Unset alarm so the extractor doesn't die when it's idle */
 		alarm (0);
 	}
diff --git a/src/tracker-extract/tracker-main.c b/src/tracker-extract/tracker-main.c
index 3445e3b..1039da0 100644
--- a/src/tracker-extract/tracker-main.c
+++ b/src/tracker-extract/tracker-main.c
@@ -71,7 +71,7 @@ static guint       quit_timeout_id = 0;
 static TrackerStorage *hal;
 
 static gboolean    version;
-gboolean           debug_mode = FALSE;
+gboolean           debug = FALSE;
 static gint        verbosity = -1;
 static gchar      *filename;
 static gchar      *mime_type;
@@ -90,15 +90,15 @@ static GOptionEntry  entries[] = {
 	  G_OPTION_ARG_FILENAME, &filename,
 	  N_("File to extract metadata for"),
 	  N_("FILE") },
-	{ "file", 'm', 0,
+	{ "mime", 'm', 0,
 	  G_OPTION_ARG_STRING, &mime_type,
 	  N_("MIME type for file (if not provided, this will be guessed)"),
 	  N_("MIME") },
 	/* Debug run is used to avoid that the mainloop exits, so that
 	 * as a developer you can be relax when running the tool in gdb */
-	{ "debug-mode", 'd', 0,
-	  G_OPTION_ARG_NONE, &debug_mode,
-	  N_("Debug mode (default = off)"),
+	{ "debug", 'd', 0,
+	  G_OPTION_ARG_NONE, &debug,
+	  N_("Debug (default = off)"),
 	  NULL },
 
 	{ NULL }
@@ -109,7 +109,7 @@ quit_timeout_cb (gpointer user_data)
 {
 	quit_timeout_id = 0;
 	
-	if (!debug_mode) {
+	if (!debug) {
 		g_main_loop_quit (main_loop);
 	} else {
 		g_debug ("Would have quit the mainloop");
@@ -312,7 +312,7 @@ main (int argc, char *argv[])
 		return EXIT_SUCCESS;
 	}
 
-	g_print ("Initializing tracker-extract...%s\n", debug_mode ? "Running in debug mode" : "");
+	g_print ("Initializing tracker-extract...%s\n", debug ? "Running in debug mode" : "");
 
 	initialize_signal_handler ();
 
diff --git a/src/tracker-utils/tracker-import.c b/src/tracker-utils/tracker-import.c
index d8c9093..2cb644a 100644
--- a/src/tracker-utils/tracker-import.c
+++ b/src/tracker-utils/tracker-import.c
@@ -46,9 +46,7 @@ main (int argc, char **argv)
 {
 	TrackerClient	*client;
 	GOptionContext	*context;
-	GError		*error = NULL;
-	GFile		*file;
-	char		*uri;
+	gchar          **p;
 
 	setlocale (LC_ALL, "");
 
@@ -58,7 +56,7 @@ main (int argc, char **argv)
 
 	/* Translators: this messagge will apper immediately after the	*/
 	/* usage string - Usage: COMMAND [OPTION]... <THIS_MESSAGE>	*/
-	context = g_option_context_new (_("- Import files"));
+	context = g_option_context_new (_("- Import data using Turtle files"));
 
 	/* Translators: this message will appear after the usage string */
 	/* and before the list of options.				*/
@@ -69,7 +67,7 @@ main (int argc, char **argv)
 		gchar *help;
 
 		g_printerr ("%s\n\n",
-			    _("File missing"));
+			    _("One or more files have not been specified"));
 
 		help = g_option_context_get_help (context, TRUE, NULL);
 		g_option_context_free (context);
@@ -89,26 +87,37 @@ main (int argc, char **argv)
 		return EXIT_FAILURE;
 	}
 
-	file = g_file_new_for_commandline_arg (filenames[0]);
-	uri = g_file_get_uri (file);
-
-	tracker_resources_load (client, uri, &error);
-
-	g_object_unref (file);
-	g_free (uri);
-
-	if (error) {
-		g_printerr ("%s, %s\n",
-			    _("Unable to import file"),
-			    error->message);
-
-		g_error_free (error);
-		tracker_disconnect (client);
-
-		return EXIT_FAILURE;
+	for (p = filenames; *p; p++) {
+		GError *error = NULL;
+		GFile  *file;
+		gchar  *uri;
+
+		g_print ("%s:'%s'\n",
+			 _("Importing Turtle file"),
+			 *p);
+
+		file = g_file_new_for_commandline_arg (*p);
+		uri = g_file_get_uri (file);
+		
+		tracker_resources_load (client, uri, &error);
+		
+		g_object_unref (file);
+		g_free (uri);
+		
+		if (error) {
+			g_printerr ("%s, %s\n",
+				    _("Unable to import Turtle file"),
+				    error->message);
+			
+			g_error_free (error);
+			continue;
+		}
+
+		g_print ("  %s\n", _("Done"));
+		g_print ("\n");
 	}
 
 	tracker_disconnect (client);
-
+	
 	return EXIT_SUCCESS;
 }
diff --git a/src/tracker-utils/tracker-info.c b/src/tracker-utils/tracker-info.c
index ea57857..6f47372 100644
--- a/src/tracker-utils/tracker-info.c
+++ b/src/tracker-utils/tracker-info.c
@@ -73,11 +73,8 @@ int
 main (int argc, char **argv)
 {
 	TrackerClient	*client;
-	gchar           *query;
 	GOptionContext	*context;
-	GError		*error = NULL;
-	GPtrArray	*results;
-	char		*uri;
+	gchar          **p;
 
 	setlocale (LC_ALL, "");
 
@@ -87,7 +84,7 @@ main (int argc, char **argv)
 
 	/* Translators: this messagge will apper immediately after the	*/
 	/* usage string - Usage: COMMAND [OPTION]... <THIS_MESSAGE>	*/
-	context = g_option_context_new (_("- Get all information from a certain file"));
+	context = g_option_context_new (_("- Get all information about one or more files"));
 
 	/* Translators: this message will appear after the usage string */
 	/* and before the list of options.				*/
@@ -98,7 +95,7 @@ main (int argc, char **argv)
 		gchar *help;
 
 		g_printerr ("%s\n\n",
-			    _("File missing"));
+			    _("One or more files have not been specified"));
 
 		help = g_option_context_get_help (context, TRUE, NULL);
 		g_option_context_free (context);
@@ -118,53 +115,64 @@ main (int argc, char **argv)
 		return EXIT_FAILURE;
 	}
 
-	/* support both, URIs and local file paths */
-	if (has_valid_uri_scheme (filenames[0])) {
-		uri = g_strdup (filenames[0]);
-	} else {
-		GFile *file;
-
-		file = g_file_new_for_commandline_arg (filenames[0]);
-		uri = g_file_get_uri (file);
-		g_object_unref (file);
-	}
-
-	query = g_strdup_printf ("SELECT ?predicate ?object WHERE { <%s> ?predicate ?object }", uri);
-
-	results = tracker_resources_sparql_query (client, query, &error);
-
-	g_free (uri);
-	g_free (query);
-
-	if (error) {
-		g_printerr ("%s, %s\n",
-			    _("Unable to retrieve data for uri"),
-			    error->message);
+        for (p = filenames; *p; p++) {
+		GPtrArray *results;
+		GError    *error = NULL;
+		gchar     *uri;
+		gchar     *query;
+
+		g_print ("%s:'%s'\n",
+			 _("Querying information for file"),
+			 *p);
+	
+		/* support both, URIs and local file paths */
+		if (has_valid_uri_scheme (*p)) {
+			uri = g_strdup (*p);
+		} else {
+			GFile *file;
+			
+			file = g_file_new_for_commandline_arg (*p);
+			uri = g_file_get_uri (file);
+			g_object_unref (file);
+		}
 		
-		g_error_free (error);
-		tracker_disconnect (client);
+		query = g_strdup_printf ("SELECT ?predicate ?object WHERE { <%s> ?predicate ?object }", uri);
 		
-		return EXIT_FAILURE;
-	}
-
-	if (!results) {
-		g_print ("%s\n",
-			 _("No metadata available for that uri"));
-	} else {
-		gint length;
-
-		length = results->len;
+		results = tracker_resources_sparql_query (client, query, &error);
+		
+		g_free (uri);
+		g_free (query);
+
+		if (error) {
+			g_printerr ("  %s, %s\n",
+				    _("Unable to retrieve data for uri"),
+				    error->message);
+			
+			g_error_free (error);
+			continue;
+		}
+		
+		if (!results) {
+			g_print ("  %s\n",
+				 _("No metadata available for that uri"));
+		} else {
+			gint length;
+			
+			length = results->len;
+			
+			g_print (tracker_dngettext (NULL,
+						    _("Result: %d"), 
+						    _("Results: %d"),
+						    length),
+				 length);
+			g_print ("\n");
+			
+			g_ptr_array_foreach (results, (GFunc) print_property_value, NULL);
+			g_ptr_array_foreach (results, (GFunc) g_strfreev, NULL);
+			g_ptr_array_free (results, TRUE);
+		}
 
-		g_print (tracker_dngettext (NULL,
-					    _("Result: %d"), 
-					    _("Results: %d"),
-					    length),
-			 length);
 		g_print ("\n");
-		
-		g_ptr_array_foreach (results, (GFunc) print_property_value, NULL);
-		g_ptr_array_foreach (results, (GFunc) g_strfreev, NULL);
-		g_ptr_array_free (results, TRUE);
 	}
 
 	tracker_disconnect (client);
diff --git a/src/tracker-utils/tracker-stats.c b/src/tracker-utils/tracker-stats.c
index b8f8bdc..86e51c4 100644
--- a/src/tracker-utils/tracker-stats.c
+++ b/src/tracker-utils/tracker-stats.c
@@ -67,7 +67,7 @@ main (int argc, char **argv)
 
 	/* Translators: this messagge will apper immediately after the	*/
 	/* usage string - Usage: COMMAND [OPTION]... <THIS_MESSAGE>	*/
-	context = g_option_context_new (_(" - Show number of indexed files for each service"));
+	context = g_option_context_new (_(" - Show statistics for all Nepomuk defined ontology classes"));
 	g_option_context_parse (context, &argc, &argv, NULL);
 	g_option_context_free (context);
 



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