summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2013-01-24 10:27:43 +0000
committerRichard Hughes <richard@hughsie.com>2013-01-24 10:27:43 +0000
commit3c19a60378e8bff959c783e7a95e239be34ddcd8 (patch)
tree325f6db1d22e5561e59ac47e0ac55b1c5eb8e017 /client
parentd69d7cdd8e45fbc6ffa74f06c8787375cddacf9a (diff)
downloadcolord-3c19a60378e8bff959c783e7a95e239be34ddcd8.tar.gz
Add a --verbose argument to colormgr
Diffstat (limited to 'client')
-rw-r--r--client/cd-util.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/client/cd-util.c b/client/cd-util.c
index 701114b..c6c0cc8 100644
--- a/client/cd-util.c
+++ b/client/cd-util.c
@@ -1959,16 +1959,32 @@ out:
}
/**
+ * cd_util_ignore_cb:
+ **/
+static void
+cd_util_ignore_cb (const gchar *log_domain, GLogLevelFlags log_level,
+ const gchar *message, gpointer user_data)
+{
+}
+
+/**
* main:
**/
int
main (int argc, char *argv[])
{
+ CdUtilPrivate *priv;
gboolean ret;
+ gboolean verbose;
+ gchar *cmd_descriptions = NULL;
GError *error = NULL;
guint retval = 1;
- CdUtilPrivate *priv;
- gchar *cmd_descriptions = NULL;
+ const GOptionEntry options[] = {
+ { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
+ /* TRANSLATORS: command line option */
+ _("Show extra debugging information"), NULL },
+ { NULL}
+ };
setlocale (LC_ALL, "");
@@ -2135,7 +2151,24 @@ main (int argc, char *argv[])
/* TRANSLATORS: program name */
g_set_application_name (_("Color Management"));
- g_option_context_parse (priv->context, &argc, &argv, NULL);
+ g_option_context_add_main_entries (priv->context, options, NULL);
+ ret = g_option_context_parse (priv->context, &argc, &argv, &error);
+ if (!ret) {
+ /* TRANSLATORS: the user didn't read the man page */
+ g_print ("%s: %s\n",
+ _("Failed to parse arguments"),
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ /* set verbose? */
+ if (verbose) {
+ g_setenv ("COLORD_VERBOSE", "1", FALSE);
+ } else {
+ g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
+ cd_util_ignore_cb, NULL);
+ }
/* get connection to colord */
priv->client = cd_client_new ();
@@ -2160,7 +2193,8 @@ main (int argc, char *argv[])
retval = 0;
out:
if (priv != NULL) {
- g_object_unref (priv->client);
+ if (priv->client != NULL)
+ g_object_unref (priv->client);
if (priv->cmd_array != NULL)
g_ptr_array_unref (priv->cmd_array);
g_option_context_free (priv->context);