save
[protos/libecoli.git] / lib / main-readline.c
index 8fecad4..87653f7 100644 (file)
 #define _GNU_SOURCE /* for asprintf */
 #include <stdlib.h>
 #include <stdio.h>
+#include <errno.h>
 #include <assert.h>
 
 #include <readline/readline.h>
 #include <readline/history.h>
 
+#include <ecoli_init.h>
 #include <ecoli_node.h>
 #include <ecoli_parsed.h>
 #include <ecoli_completed.h>
@@ -55,7 +57,7 @@ static char *my_completion_entry(const char *s, int state)
 {
        static struct ec_completed *c;
        static struct ec_completed_iter *iter;
-       static const struct ec_completed_item *item;
+       const struct ec_completed_item *item;
 
        (void)s;
 
@@ -258,7 +260,7 @@ static int create_commands(void)
        ec_keyval_set(ec_node_attrs(ec_node_find(cmd, "name")), "help",
                "the person to greet", NULL);
        ec_keyval_set(ec_node_attrs(ec_node_find(cmd, "count")), "help",
-               "how many times to greet", NULL);
+               "how many times to greet (0-10)", NULL);
        if (ec_node_or_add(cmdlist, cmd) < 0)
                goto fail;
 
@@ -324,6 +326,11 @@ int main(void)
        struct ec_parsed *p;
        char *line;
 
+       if (ec_init() < 0) {
+               fprintf(stderr, "cannot init ecoli: %s\n", strerror(errno));
+               return 1;
+       }
+
        if (create_commands() < 0)
                return 1;