resolver: added console dump command.
authorKrisztian Litkey <kli@iki.fi>
Mon, 16 Sep 2013 12:41:31 +0000 (15:41 +0300)
committerKrisztian Litkey <kli@iki.fi>
Wed, 18 Sep 2013 13:12:27 +0000 (16:12 +0300)
src/Makefile.am
src/resolver/console.c [new file with mode: 0644]

index 422fc32..41dc848 100644 (file)
@@ -630,6 +630,7 @@ libmurphy_resolver_la_REGULAR_SOURCES =                             \
                resolver/target-sorter.c                        \
                resolver/fact.c                                 \
                resolver/events.c                               \
+               resolver/console.c                              \
                $(SIMPLE_SCRIPT_SOURCES)
 
 libmurphy_resolver_la_SOURCES =                        \
diff --git a/src/resolver/console.c b/src/resolver/console.c
new file mode 100644 (file)
index 0000000..d1628a4
--- /dev/null
@@ -0,0 +1,30 @@
+#include <murphy/core/console.h>
+#include <murphy/resolver/resolver.h>
+
+static void dump(mrp_console_t *c, void *user_data, int argc, char **argv)
+{
+    mrp_context_t *ctx = c->ctx;
+
+    MRP_UNUSED(user_data);
+    MRP_UNUSED(argc);
+    MRP_UNUSED(argv);
+
+    if (ctx->r != NULL) {
+        mrp_resolver_dump_facts(ctx->r, c->stdout);
+        mrp_resolver_dump_targets(ctx->r, c->stdout);
+    }
+}
+
+#define RESOLVER_DESCRIPTION                                              \
+    "Resolver commands provide runtime diagnostics and debugging for\n"   \
+    "the Murphy resolver.\n"
+
+#define DUMP_SYNTAX  "dump"
+#define DUMP_SUMMARY "dump the resolver facts and targets"
+#define DUMP_DESCRIPTION                        \
+    "Dump the resolver facts and targets.\n"
+
+MRP_CORE_CONSOLE_GROUP(resolver_group, "resolver", RESOLVER_DESCRIPTION, NULL, {
+        MRP_TOKENIZED_CMD("dump", dump, FALSE,
+                          DUMP_SYNTAX, DUMP_SUMMARY, DUMP_DESCRIPTION),
+});