From 51f636bc6b95c70a886235f227092662f16b879a Mon Sep 17 00:00:00 2001 From: lohhiiccc Date: Mon, 18 May 2026 13:43:41 +0200 Subject: [PATCH] feat: usage in --help --- includes/internal/cli/option.h | 2 ++ src/cli/handlers/handle_help.c | 4 ++++ src/cli/parse.c | 3 +-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/includes/internal/cli/option.h b/includes/internal/cli/option.h index 9bb069a..fd626bb 100644 --- a/includes/internal/cli/option.h +++ b/includes/internal/cli/option.h @@ -65,4 +65,6 @@ enum { FT_SSL_OPT_LEN = (0 FT_SSL_OPTION_LIST ) }; enum { FT_SSL_OPTSTR_LEN = (2 FT_SSL_OPTION_LIST) }; /* +2 for ':' to disable getopt error messages and \0 */ +void print_usage(const char *prog); + #endif diff --git a/src/cli/handlers/handle_help.c b/src/cli/handlers/handle_help.c index 2b727dd..7bb4d39 100644 --- a/src/cli/handlers/handle_help.c +++ b/src/cli/handlers/handle_help.c @@ -1,11 +1,15 @@ #include +#include #include "compiler.h" +#include "version_gen.h" #include "internal/cli/option.h" #include "internal/cli/cli_handlers.h" int cli_handle_help(__unused const char *arg, __unused void *config_void) { + print_usage(g_prog_name); + printf("\n"); cli_print_options(g_options, FT_SSL_OPT_LEN, cli_arg_type_to_str); return CLI_EXIT_SUCCESS; } diff --git a/src/cli/parse.c b/src/cli/parse.c index cfac06b..3cf9a0e 100644 --- a/src/cli/parse.c +++ b/src/cli/parse.c @@ -12,7 +12,6 @@ /* Forward declarations */ static void init_config(struct ssl_config *config); -static void print_usage(const char *prog); static const struct digest_algo *find_algo(const char *name); static enum cli_code parse_subcommand(int argc, char **argv, int first_arg, struct ssl_config *config); @@ -70,7 +69,7 @@ find_algo(const char *name) return NULL; } -static void +void print_usage(const char *prog) { size_t i;