common.h (880B)
1 #ifndef UDPHOLE_CLI_COMMON_H 2 #define UDPHOLE_CLI_COMMON_H 3 4 #include <stddef.h> 5 #include <stdio.h> 6 7 struct cli_command { 8 void *next; 9 const char *cmd; 10 const char *desc; 11 int (*fn)(int, const char **); 12 }; 13 14 extern struct cli_command *cli_commands; 15 16 const char *cli_find_arg(int argc, const char **argv, const char *name); 17 18 size_t cli_collect_positional(int argc, const char **argv, int start, 19 const char **out, size_t max_out); 20 21 void cli_set_config_path(const char *path); 22 const char *cli_config_path(void); 23 24 const char *cli_resolve_default_config(void); 25 26 int cli_get_output_width(int default_width); 27 28 void cli_print_wrapped(FILE *out, const char *text, int width, int left_col_width); 29 30 void cli_register_command(const char *name, const char *description, int (*fn)(int, const char **)); 31 int cli_execute_command(int argc, const char **argv); 32 33 #endif // UDPHOLE_CLI_COMMON_H