diff --git a/src/creds/creds.c b/src/creds/creds.c index ac405eb3e8..c0908d89ec 100644 --- a/src/creds/creds.c +++ b/src/creds/creds.c @@ -7,6 +7,7 @@ #include "sd-varlink.h" #include "alloc-util.h" +#include "ansi-color.h" #include "build.h" #include "bus-polkit.h" #include "bus-util.h" @@ -24,12 +25,10 @@ #include "log.h" #include "main-func.h" #include "memory-util.h" -#include "options.h" #include "pager.h" #include "parse-argument.h" #include "parse-util.h" #include "polkit-agent.h" -#include "pretty-print.h" #include "stat-util.h" #include "string-table.h" #include "string-util.h" @@ -79,6 +78,13 @@ static bool arg_ask_password = true; STATIC_DESTRUCTOR_REGISTER(arg_tpm2_public_key, freep); STATIC_DESTRUCTOR_REGISTER(arg_tpm2_signature, freep); +COMMAND( + "systemd-creds\0", + "Display and process credentials.", + .man_pages = "systemd-creds.1\0", + .pager_flags = &arg_pager_flags, +); + static const char* transcode_mode_table[_TRANSCODE_MAX] = { [TRANSCODE_OFF] = "off", [TRANSCODE_BASE64] = "base64", @@ -773,51 +779,7 @@ static int verb_has_tpm2(int argc, char *argv[], uintptr_t _data, void *userdata return verb_has_tpm2_generic(arg_quiet); } -static int help(void) { - _cleanup_free_ char *link = NULL; - _cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL; - int r; - - r = terminal_urlify_man("systemd-creds", "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" - "%sDisplay and Process Credentials.%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(help); +VERB_COMMON_HELP_AUTO("systemd-creds"); static int parse_argv(int argc, char *argv[], char ***ret_args) { assert(argc >= 0); @@ -830,7 +792,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-creds"); OPTION_COMMON_VERSION: return version(); @@ -1022,6 +984,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { OPTION('q', "quiet", NULL, "Suppress informational messages"): arg_quiet = true; break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(arg_json_format_flags); } SET_FLAG(arg_credential_flags, CREDENTIAL_IPC_ALLOW_INTERACTIVE, arg_ask_password); diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index 54a34f97ea..c4a0ec8697 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -28,6 +28,7 @@ INTROSPECTABLE=( systemd-cgls systemd-cgtop systemd-clonesetup + systemd-creds systemd-delta systemd-detect-virt systemd-dissect