diff --git a/src/keyutil/keyutil.c b/src/keyutil/keyutil.c index 51c83478eb..c442cf30e9 100644 --- a/src/keyutil/keyutil.c +++ b/src/keyutil/keyutil.c @@ -1,5 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include "sd-json.h" + #include "alloc-util.h" #include "ask-password-api.h" #include "build.h" @@ -7,13 +9,10 @@ #include "dlopen-note.h" #include "fd-util.h" #include "fileio.h" -#include "format-table.h" #include "fs-util.h" #include "log.h" #include "main-func.h" -#include "options.h" #include "parse-argument.h" -#include "pretty-print.h" #include "string-util.h" #include "tmpfile-util.h" #include "verbs.h" @@ -37,51 +36,13 @@ STATIC_DESTRUCTOR_REGISTER(arg_signature, freep); STATIC_DESTRUCTOR_REGISTER(arg_content, freep); STATIC_DESTRUCTOR_REGISTER(arg_output, freep); -static int help(void) { - _cleanup_free_ char *link = NULL; - _cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL; - int r; +COMMAND( + "systemd-keyutil\0", + "Perform various operations on private keys and certificates.", + .man_pages = "systemd-keyutil.1\0", +); - r = terminal_urlify_man("systemd-keyutil", "1", &link); - if (r < 0) - return log_oom(); - - r = verbs_get_help_table(&verbs); - if (r < 0) - return r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - (void) table_sync_column_widths(0, verbs, options); - - printf("%s [OPTIONS...] COMMAND ...\n\n" - "%sPerform various operations on private keys and certificates.%s\n" - "\n%sCommands:%s\n", - program_invocation_short_name, - ansi_highlight(), - ansi_normal(), - ansi_underline(), - ansi_normal()); - - r = table_print_or_warn(verbs); - if (r < 0) - return r; - - printf("\n%sOptions:%s\n", - ansi_underline(), - ansi_normal()); - - r = table_print_or_warn(options); - if (r < 0) - return r; - - printf("\nSee the %s for details.\n", link); - return 0; -} - -VERB_COMMON_HELP_HIDDEN(help); +VERB_COMMON_HELP_AUTO_HIDDEN("systemd-keyutil"); static int parse_argv(int argc, char *argv[], char ***ret_args) { assert(argc >= 0); @@ -95,7 +56,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-keyutil"); OPTION_COMMON_VERSION: return version(); @@ -152,6 +113,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { if (r < 0) return r; break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } if (arg_private_key_source && !arg_certificate) diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index e7d19f8b5c..aabbc4d37d 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -47,6 +47,7 @@ INTROSPECTABLE=( systemd-journal-gatewayd systemd-journal-remote systemd-journal-upload + systemd-keyutil systemd-modules-load systemd-mute-console systemd-network-generator