[gegl] Bug 704988 - Add options to gegl binary to list/test operation existence
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] Bug 704988 - Add options to gegl binary to list/test operation existence
- Date: Mon, 2 Sep 2013 12:22:53 +0000 (UTC)
commit 48428e97910ee169a69008a54b15c31f9f6e8cd4
Author: Jehan <jehan girinstud io>
Date: Sun Jul 28 03:09:16 2013 +1200
Bug 704988 - Add options to gegl binary to list/test operation existence
Adding 3 options to the `gegl` binary, inspired by pkg-config:
--list-all for listing all available operations;
--exists for testing operation(s) availability;
--properties for pretty-printing the property list of an operation.
bin/gegl-options.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 95 insertions(+), 0 deletions(-)
---
diff --git a/bin/gegl-options.c b/bin/gegl-options.c
index 882eb36..452f4b0 100644
--- a/bin/gegl-options.c
+++ b/bin/gegl-options.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include "gegl-options.h"
+#include <gegl.h>
static GeglOptions *opts_new (void)
{
@@ -47,6 +48,12 @@ _("usage: %s [options] <file | -- [op [op] ..]>\n"
" Options:\n"
" -h, --help this help information\n"
"\n"
+" --list-all list all known operations\n"
+"\n"
+" --exists return 0 if the operation(s) exist\n"
+"\n"
+" --properties output the properties (name, type, description) of the operation\n"
+"\n"
" -i, --file read xml from named file\n"
"\n"
" -x, --xml use xml provided in next argument\n"
@@ -212,6 +219,94 @@ parse_args (int argc,
usage (argv[0]);
}
+ else if (match ("--list-all")) {
+ guint n_operations;
+ gchar **operations = gegl_list_operations (&n_operations);
+ gint i;
+
+ for (i = 0; i < n_operations; i++)
+ {
+ fprintf (stdout, "%s\n", operations[i]);
+ }
+ g_free (operations);
+
+ exit (0);
+ }
+
+ else if (match ("--exists")) {
+ guint n_operations;
+ gchar **operations = gegl_list_operations (&n_operations);
+ GList *op_names = NULL;
+ gchar *op_name;
+ gboolean all_found;
+ gint i;
+
+ /* The option requires at least one argument. */
+ get_string (op_name);
+ while (op_name)
+ {
+ op_names = g_list_prepend (op_names, g_strdup (op_name));
+ get_string_forced (op_name);
+ }
+
+ for (i = 0; i < n_operations; i++)
+ {
+ GList *found_element;
+
+ while ((found_element =
+ g_list_find_custom (op_names,
+ operations[i],
+ (GCompareFunc) g_strcmp0)) != NULL)
+ op_names = g_list_delete_link (op_names, found_element);
+ }
+
+ all_found = (g_list_length (op_names) == 0);
+
+ g_free (operations);
+ g_list_free_full (op_names, g_free);
+
+ exit (all_found ? 0 : 1);
+ }
+
+ else if (match ("--properties")) {
+ guint n_operations;
+ gchar **operations = gegl_list_operations (&n_operations);
+ gchar *op_name;
+ gint i;
+
+ get_string (op_name);
+
+ for (i = 0; i < n_operations; i++)
+ {
+ if (g_strcmp0 (operations[i], op_name) == 0)
+ {
+ guint n_properties;
+ GParamSpec **properties;
+
+ properties = gegl_operation_list_properties (op_name, &n_properties);
+ for (i = 0; i < n_properties; i++)
+ {
+ const gchar *property_name;
+ const gchar *property_blurb;
+
+ property_name = g_param_spec_get_name (properties[i]);
+ property_blurb = g_param_spec_get_blurb (properties[i]);
+
+ fprintf (stdout, "%-30s [%s] %s\n",
+ property_name,
+ g_type_name (properties[i]->value_type),
+ property_blurb);
+ }
+
+ g_free (properties);
+ exit (0);
+ }
+ }
+ g_free (operations);
+
+ exit (1);
+ }
+
else if (match ("--verbose") ||
match ("-v")) {
o->verbose=1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]