diff --git a/src/shared/help-util.c b/src/shared/help-util.c index 8968ba1377..268f51bb74 100644 --- a/src/shared/help-util.c +++ b/src/shared/help-util.c @@ -1,31 +1,15 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include #include -#include "alloc-util.h" #include "ansi-color.h" #include "help-util.h" #include "path-util.h" -#include "pretty-print.h" -/* These are helpers for putting together --help texts in a uniform way with a common output style. Each - * function generates a separate part of the --help text: - * - * 1. help_cmdline() outputs a brief summary of the command line syntax. This shall be used at least once, - * in some cases multiple times. This generally comes first in the output. - * - * 2. help_abstract() outputs a brief prose abstract of the command, should carry a single line of text - * that gives the user a hint what this tool does. Use only once, right after the last help_cmdline(). - * - * 3. help_section() can be used to format multiple sections of the --help text. It should be used at least - * once for an "Options:" section, but can be used more than once, for programs with many - * options/verbs. The first invocation should come right after help_abstract(). - * - * 4. Finally, help_man_page_reference() adds a final line linking the man page of the tool. This should be - * used only once, and terminates the --help text. - * - * Switches and verbs documentation should be inserted after each help_section(). For that ideally use - * options.[ch] APIs. */ +/* These are helpers for putting together --help texts in a uniform way with a common output style: + * help_cmdline() outputs a brief summary of the command line syntax, and help_section() formats the + * headings of the individual sections of the --help text. */ void help_cmdline(const char *arguments) { const char *progname = @@ -41,16 +25,6 @@ void help_cmdline(const char *arguments) { arguments); } -void help_abstract(const char *text) { - assert(text); - - printf("\n%s%s%s%s\n", - ansi_highlight(), - ansi_add_italics(), - text, - ansi_normal()); -} - void help_section(const char *title) { assert(title); @@ -59,16 +33,3 @@ void help_section(const char *title) { title, ansi_normal()); } - -void help_man_page_reference(const char *page, const char *section) { - assert(page); - assert(section); - - /* Displaying --help texts generally should not fail, hence let's fall back to a simple string in - * case of OOM. */ - _cleanup_free_ char *link = NULL; - if (terminal_urlify_man(page, section, &link) < 0) - printf("\nSee the %s(%s) man page for details.\n", page, section); - else - printf("\nSee the %s for details.\n", link); -} diff --git a/src/shared/help-util.h b/src/shared/help-util.h index 380487213f..9b1072c720 100644 --- a/src/shared/help-util.h +++ b/src/shared/help-util.h @@ -3,8 +3,4 @@ void help_cmdline(const char *arguments); -void help_abstract(const char *text); - void help_section(const char *title); - -void help_man_page_reference(const char *page, const char *section); diff --git a/src/shared/verbs.c b/src/shared/verbs.c index 7d6c324259..d63e069bae 100644 --- a/src/shared/verbs.c +++ b/src/shared/verbs.c @@ -270,7 +270,7 @@ const Verb* _verbs_find_command( return NULL; } -int _verbs_get_help_table( +static int verbs_get_help_table( const Verb verbs[], const Verb verbs_end[], const char *group, @@ -292,13 +292,8 @@ int _verbs_get_help_table( const Verb *verb; for (verb = verbs; verb < verbs_end; verb++) { - /* Binaries with one or more VERB_COMMAND entries call this function - * through print_verb_option_help() which provides a verbs slice that - * starts after the VERB_COMMAND entry. - * - * In unconverted binaries, this function is called directly. */ - // TODO: make this function static after everything has been converted. - + /* This function is called through print_verb_option_help(), which provides a verbs + * slice that starts after the VERB_COMMAND entry. */ if (FLAGS_SET(verb->flags, VERB_COMMAND_MARKER)) break; @@ -364,7 +359,7 @@ static int print_verb_option_help( const char *group = FLAGS_SET(verb->flags, VERB_GROUP_MARKER) ? verb->verb : NULL; _cleanup_(table_unrefp) Table *table = NULL; - r = _verbs_get_help_table(verb, verbs_end, group, &table); + r = verbs_get_help_table(verb, verbs_end, group, &table); if (r < 0) return r; diff --git a/src/shared/verbs.h b/src/shared/verbs.h index 3453c5e72a..ccfc403bab 100644 --- a/src/shared/verbs.h +++ b/src/shared/verbs.h @@ -140,29 +140,6 @@ int _dispatch_verb(char **args, const Verb verbs[], const Verb verbs_end[], void #define dispatch_verb(args, userdata) \ _dispatch_verb(args, __start_SYSTEMD_VERBS, __stop_SYSTEMD_VERBS, userdata) -int _verbs_get_help_table( - const Verb verbs[], - const Verb verbs_end[], - const char *group, - Table **ret); -#define verbs_get_help_table_group(group, ret) \ - _verbs_get_help_table(__start_SYSTEMD_VERBS, __stop_SYSTEMD_VERBS, group, ret) -#define verbs_get_help_table(ret) \ - verbs_get_help_table_group(/* group= */ NULL, ret) - -#define _VERB_COMMON_HELP_IMPL(impl) \ - static int verb_help(int argc, char **argv, uintptr_t data, void *userdata) { \ - return impl(); \ - } - -#define VERB_COMMON_HELP(impl) \ - VERB(verb_help, "help", NULL, VERB_ANY, VERB_ANY, 0, "Show this help"); \ - _VERB_COMMON_HELP_IMPL(impl) - -#define VERB_COMMON_HELP_HIDDEN(impl) \ - VERB(verb_help, "help", NULL, VERB_ANY, VERB_ANY, 0, NULL); \ - _VERB_COMMON_HELP_IMPL(impl) - #define VERB_COMMON_HELP_AUTO_FULL(program, help) \ VERB_FULL(verb_help_auto, "help", NULL, VERB_ANY, VERB_ANY, 0, /* dat= */ (uintptr_t) program, /* help= */ help) #define VERB_COMMON_HELP_AUTO_PROGRAM(program) VERB_COMMON_HELP_AUTO_FULL(program, "Show this help")