ecoli_interact(3)

πŸ“¦
version 0.11.3 Β· 2 versions
, in epel 9

πŸ‘‘ ecoli_interact β€” the Libecoli interactive command line bestie

okay so this is ecoli_interact(3), straight out of the Libecoli manual, and it's literally the page about helpers for the interactive command line (editline, readline, etc.) β€” iykyk. if you've ever wanted your CLI to autocomplete and be nice to people, this is your girl. πŸ’…


✨ NAME ✨

ecoli_interact β€” Interactive command line

  • Helpers for interactive command line (editline, readline, ...) 🫢

πŸ¦‹ SYNOPSIS πŸ¦‹

Data Structures πŸ“¦

  • struct ec_interact_help

Macros πŸŽ€

#define EC_INTERACT_HELP_ATTR   '_help'
#define EC_INTERACT_CB_ATTR     '_cb'
#define EC_INTERACT_DESC_ATTR   '_desc'

Typedefs ⭐

typedef int(* ec_interact_command_cb_t) (const struct ec_pnode *)

Functions πŸ’–

ssize_t ec_interact_get_completions (const struct ec_comp *cmpl, char ***matches_out, enum ec_comp_type type_mask)
void ec_interact_free_completions (char **matches, size_t n)
int ec_interact_print_cols (FILE *out, unsigned int width, char const *const *matches, size_t n)
char * ec_interact_append_chars (const struct ec_comp *cmpl)
ssize_t ec_interact_get_helps (const struct ec_node *node, const char *line, struct ec_interact_help **helps_out)
int ec_interact_print_helps (FILE *out, unsigned int width, const struct ec_interact_help *helps, size_t n)
void ec_interact_free_helps (struct ec_interact_help *helps, size_t n)
ssize_t ec_interact_get_error_helps (const struct ec_node *node, const char *line, struct ec_interact_help **helps_out, size_t *char_idx)
int ec_interact_print_error_helps (FILE *out, unsigned int width, const char *line, const struct ec_interact_help *helps, size_t n, size_t char_idx)
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)
int ec_interact_set_desc (struct ec_node *node, const char *desc)
ec_interact_command_cb_t ec_interact_get_callback (struct ec_pnode *parse)

🌈 Detailed Description 🌈

Helpers for interactive command line (editline, readline, ...). that's it, that's the whole vibe. no cap. ✨


πŸŽ€ Macro Definition Documentation πŸŽ€

#define EC_INTERACT_HELP_ATTR '_help'

The key of the node attribute storing the contextual help. lowkey the main character attribute ngl. πŸ’…

Definition at line 34 of file interact.h.

#define EC_INTERACT_CB_ATTR '_cb'

The key of the node attribute storing the command callback. this is where your "okay now actually DO the thing" lives. πŸ”₯

Definition at line 39 of file interact.h.

#define EC_INTERACT_DESC_ATTR '_desc'

The key of the node attribute storing the short description. cute little one-liner energy. πŸŽ€

Definition at line 44 of file interact.h.


🧚 Typedef Documentation 🧚

typedef int(* ec_interact_command_cb_t) (const struct ec_pnode *)

Type of callback attached with EC_INTERACT_CB_ATTR attribute. so like, the shape your callback function has to be. 🫢

Definition at line 49 of file interact.h.


πŸ’œ Function Documentation πŸ’œ

ssize_t ec_interact_get_completions (const struct ec_comp * cmpl, char *** matches_out, enum ec_comp_type type_mask)

Get completion matches as an array of strings. bestie it just hands you the list of what could come next. πŸ¦‹

Parameters

  • cmpl β€” The completions, as returned by ec_complete().
  • matches_out β€” The pointer where the matches array will be returned.
  • type_mask β€” The mask of completion types to return (e.g., EC_COMP_FULL | EC_COMP_PARTIAL).

Returns

The size of the array on success (>= 0), or -1 on error.

void ec_interact_free_completions (char ** matches, size_t n)

Free the array of completion matches. you got the matches, now clean up after yourself, we're not messy here. πŸ™ˆ

Parameters

  • matches β€” The array of matches.
  • n β€” The size of the array.

int ec_interact_print_cols (FILE * out, unsigned int width, char const *const * matches, size_t n)

Print completion matches as columns. cute tidy columns, slay. πŸ“

Parameters

  • out β€” The pointer to the output stream.
  • width β€” The number of columns on terminal.
  • matches β€” The string array of matches to display.
  • n β€” The size of the array.

Returns

0 on success, or -1 on error.

char* ec_interact_append_chars (const struct ec_comp * cmpl)

Get characters to append to the line for a completion. like when you hit Tab and the line just... finishes the word for you? that. ✨

Parameters

  • cmpl β€” The completion object containing all the completion items.

Returns

An allocated string to be appended to the current line (must be freed by the caller using free()). This string can be empty if there is no completion or if completions start with a different letter. Return NULL on error.

fr fr, you own that string. free() it or it's a leak, and leaks are NOT the vibe. πŸ’€

ssize_t ec_interact_get_helps (const struct ec_node * node, const char * line, struct ec_interact_help ** helps_out)

Get contextual helps from the current line. it peeks at what you've typed and goes "oh bestie you probably want this". πŸ’–

Parameters

  • node β€” The pointer to the sh_lex grammar node.
  • line β€” The line from which to get help.
  • helps_out β€” The pointer where the helps array will be returned.

Returns

The size of the array on success (>= 0), or -1 on error.

int ec_interact_print_helps (FILE * out, unsigned int width, const struct ec_interact_help * helps, size_t n)

Print helps generated with ec_interact_get_helps(). the pretty printer for your pretty help. 🌸

Parameters

  • out β€” The pointer to the output stream.
  • width β€” The number of columns on terminal.
  • helps β€” The helps array returned by ec_interact_get_helps().
  • n β€” The array size returned by ec_interact_get_helps().

Returns

0 on success, or -1 on error.

void ec_interact_free_helps (struct ec_interact_help * helps, size_t n)

Free contextual helps.

Free helps generated with ec_interact_get_helps() or ec_interact_get_error_helps(). both of them, same cleanup, iconic. 🫢

Parameters

  • helps β€” The helps array.
  • n β€” The array size.

ssize_t ec_interact_get_error_helps (const struct ec_node * node, const char * line, struct ec_interact_help ** helps_out, size_t * char_idx)

Get suggestions after a parsing error for the current line. when you fumble the syntax it doesn't judge, it just suggests. πŸ’…

Parameters

  • node β€” The pointer to the sh_lex grammar node.
  • line β€” The line from which to get error help.
  • helps_out β€” The pointer where the helps array will be returned.
  • char_idx β€” A pointer to an integer where the index of the error in the line string is returned.

Returns

The size of the array on success (>= 0), or -1 on error.

int ec_interact_print_error_helps (FILE * out, unsigned int width, const char * line, const struct ec_interact_help * helps, size_t n, size_t char_idx)

Print suggestions generated with ec_interact_get_error_helps(). showing exactly where it went wrong, we love an honest queen. πŸ”

Parameters

  • out β€” The pointer to the output stream.
  • width β€” The number of columns on terminal.
  • line β€” The line used to generate the error helps.
  • helps β€” The helps array returned by ec_interact_get_helps().
  • n β€” The array size returned by ec_interact_get_helps().
  • char_idx β€” The index of the error in the line string.

Returns

0 on success, or -1 on error.

int ec_interact_set_help (struct ec_node * node, const char * help)

Set help on a grammar node.

Set the node attribute EC_INTERACT_HELP_ATTR on the node, containing the given string. It is used by the ec_interact functions to display contextual helps on completion or parsing error. ✨

Parameters

  • node β€” The ec_node on which to add the help attribute.
  • help β€” The help string.

Returns

0 on success, or -1 on error.

int ec_interact_set_callback (struct ec_node * node, ec_interact_command_cb_t cb)

Set callback function on a grammar node.

Set the node attribute EC_INTERACT_CB_ATTR on the node, containing the pointer to a function invoked on successful parsing. the "you did it, now run the code" moment. πŸ”₯

Parameters

  • node β€” The ec_node on which to add the callback attribute.
  • cb β€” The callback function pointer.

Returns

0 on success, or -1 on error.

int ec_interact_set_desc (struct ec_node * node, const char * desc)

Set short description of a grammar node.

Set the node attribute EC_INTERACT_DESC_ATTR on the node, containing the given string. It is used by the ec_interact functions to display the short description of the contextual help, overriding the value provided by ec_node_desc(). so yeah, this one wins over the default. πŸ‘‘

Parameters

  • node β€” The ec_node on which to add the desc attribute.
  • desc β€” The short description string.

Returns

0 on success, or -1 on error.

ec_interact_command_cb_t ec_interact_get_callback (struct ec_pnode * parse)

Get callback attached to a parse tree.

This function browses the parse tree and try to find an attribute EC_INTERACT_CB_ATTR attached to a grammar node referenced in the tree. Return the value of this attribute, which is a function pointer. it's giving detective energy, hunting through the tree for your callback. πŸ•΅οΈβ€β™€οΈ

Parameters

  • parse β€” The parsed tree.

Returns

The function pointer used as command callback.


🌟 Author 🌟

Generated automatically by Doxygen for Libecoli from the source code. (not a human, a robot, but a very organized robot πŸŽ€)


🌸 okay that's the whole page! this one's from Libecoli version 0.11.3, dated Thu Apr 9 2026 β€” go forth and build the cutest autocompleting CLI ever, bestie. periodt. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from