#include #include #include #include "cli.h" #include "cli_opt.h" #include "ft_ping.h" /* Forward declarations */ static const char * option_arg_type_to_str(t_option_arg_type type); /* -------------------- */ int cli_handle_help(const char *arg, t_ping_config *config) { (void)config; (void)arg; printf("ft_ping - Send ICMP ECHO_REQUEST to network hosts\n"); printf("Usage: ft_ping [options] \n\n"); printf("Options:\n"); for (size_t i = 0; i < CLI_OPT_LEN; ++i) { const t_option_descriptor *opt = &g_options[i]; const char *argstr = option_arg_type_to_str(opt->arg_type); printf(" -%c, --%-10s %-8s %s\n", opt->short_opt, opt->long_opt, argstr[0] ? argstr : "", opt->description ); } return CLI_EXIT_SUCCESS; } static const char * option_arg_type_to_str(t_option_arg_type type) { switch (type) { case OPT_ARG_NONE: return ""; case OPT_ARG_INT: return ""; case OPT_ARG_UINT: return ""; case OPT_ARG_SECONDS: return ""; case OPT_ARG_BYTES: return ""; case OPT_ARG_TTL: return ""; case OPT_ARG_STRING: return ""; default: return ""; } }