33#define ID_NAME "id_name"
34#define ID_JOHN "id_john"
35#define ID_COUNT "id_count"
40static int hello_cb(
const struct ec_pnode *parse)
48 printf(
"you say hello to %s", name);
50 printf(
" %s times", count);
56static int bye_cb(
const struct ec_pnode *parse)
61 printf(
"you say bye to %s\n", name);
66static int exit_cb(
const struct ec_pnode *parse)
76static int check_exit(
void *opaque)
82static struct ec_node *create_commands(
void)
84 struct ec_node *cmdlist = NULL, *cmd = NULL;
159 fprintf(stderr,
"cannot initialize nodes\n");
172 fprintf(stderr,
"cannot init ecoli: %s\n", strerror(errno));
176 node = create_commands();
178 fprintf(stderr,
"failed to create commands: %s\n", strerror(errno));
182 editline =
ec_editline(
"simple-editline", stdin, stdout, stderr, 0);
183 if (editline == NULL) {
184 fprintf(stderr,
"Failed to initialize editline\n");
189 fprintf(stderr,
"Failed to set prompt\n");
int ec_editline_set_prompt(struct ec_editline *editline, const char *prompt)
struct ec_editline * ec_editline(const char *prog, FILE *f_in, FILE *f_out, FILE *f_err, enum ec_editline_init_flags flags)
void ec_editline_free(struct ec_editline *editline)
int ec_editline_interact(struct ec_editline *editline, ec_editline_check_exit_cb_t check_exit_cb, void *opaque)
int ec_editline_set_node(struct ec_editline *editline, const struct ec_node *node)
int ec_interact_set_help(struct ec_node *node, const char *help)
int ec_interact_set_callback(struct ec_node *node, ec_interact_command_cb_t cb)
struct ec_node * ec_node_int(const char *id, int64_t min, int64_t max, unsigned int base)
struct ec_node * ec_node_option(const char *id, struct ec_node *node)
int ec_node_or_add(struct ec_node *node, struct ec_node *child)
#define EC_NODE_OR(args...)
#define EC_NODE_SEQ(args...)
struct ec_node * ec_node_sh_lex(const char *id, struct ec_node *child)
struct ec_node * ec_node_str(const char *id, const char *str)
struct ec_node * ec_node_clone(struct ec_node *node)
struct ec_node * ec_node(const char *typename, const char *id)
struct ec_node * ec_node_find(struct ec_node *node, const char *id)
void ec_node_free(struct ec_node *node)
const struct ec_strvec * ec_pnode_get_strvec(const struct ec_pnode *pnode)
const struct ec_pnode * ec_pnode_find(const struct ec_pnode *root, const char *id)
struct ec_pnode * ec_pnode(const struct ec_node *node)
const char * ec_strvec_val(const struct ec_strvec *strvec, size_t idx)