#ifndef CLI_H #define CLI_H #include #include #include "compiler.h" enum e_cli_code { CLI_EXIT_SUCCESS = -1, CLI_SUCCESS = 0, CLI_ERROR = 1 }; typedef int (*t_option_handler)(const char *arg, void *config); typedef enum e_option_arg_type { OPT_ARG_NONE = 0, OPT_ARG_INT, OPT_ARG_UINT, OPT_ARG_SECONDS, OPT_ARG_BYTES, OPT_ARG_TTL, OPT_ARG_STRING } t_option_arg_type; typedef struct s_option_descriptor { char short_opt; const char *long_opt; int has_arg; t_option_handler handler; t_option_arg_type arg_type; const char *description; } t_option_descriptor; enum e_cli_code cli_parse(int argc, char **argv, void *config, const t_option_descriptor *opts, size_t nb_opts, char *opt_str, struct option *long_opts); #endif