shared: fold help-util.c into verbs.c
Only one trivial function needs to be non-static and that is not enough to justify two separate files.
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ansi-color.h"
|
||||
#include "help-util.h"
|
||||
#include "path-util.h"
|
||||
|
||||
/* 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 =
|
||||
last_path_component(secure_getenv("SYSTEMD_INVOKED_AS"))
|
||||
?: program_invocation_short_name;
|
||||
|
||||
assert(arguments);
|
||||
|
||||
printf("%s>%s %s %s\n",
|
||||
ansi_grey(),
|
||||
ansi_normal(),
|
||||
progname,
|
||||
arguments);
|
||||
}
|
||||
|
||||
void help_section(const char *title) {
|
||||
assert(title);
|
||||
|
||||
printf("\n%s%s:%s\n",
|
||||
ansi_underline(),
|
||||
title,
|
||||
ansi_normal());
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
void help_cmdline(const char *arguments);
|
||||
|
||||
void help_section(const char *title);
|
||||
@@ -95,7 +95,6 @@ shared_sources = files(
|
||||
'gnutls-util.c',
|
||||
'gpt.c',
|
||||
'group-record.c',
|
||||
'help-util.c',
|
||||
'hibernate-util.c',
|
||||
'hostname-setup.c',
|
||||
'hwdb-util.c',
|
||||
|
||||
+24
-1
@@ -6,11 +6,11 @@
|
||||
#include "env-util.h"
|
||||
#include "extract-word.h"
|
||||
#include "format-table.h"
|
||||
#include "help-util.h"
|
||||
#include "log.h"
|
||||
#include "nulstr-util.h"
|
||||
#include "options.h"
|
||||
#include "pager.h"
|
||||
#include "path-util.h"
|
||||
#include "pretty-print.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
@@ -513,6 +513,29 @@ static const Verb* verbs_find_cmd_verbs(const Verb *cmdverb, const Verb verbs_en
|
||||
return actual;
|
||||
}
|
||||
|
||||
static void help_cmdline(const char *arguments) {
|
||||
const char *progname =
|
||||
last_path_component(secure_getenv("SYSTEMD_INVOKED_AS"))
|
||||
?: program_invocation_short_name;
|
||||
|
||||
assert(arguments);
|
||||
|
||||
printf("%s>%s %s %s\n",
|
||||
ansi_grey(),
|
||||
ansi_normal(),
|
||||
progname,
|
||||
arguments);
|
||||
}
|
||||
|
||||
void help_section(const char *title) {
|
||||
assert(title);
|
||||
|
||||
printf("\n%s%s:%s\n",
|
||||
ansi_underline(),
|
||||
title,
|
||||
ansi_normal());
|
||||
}
|
||||
|
||||
int _command_print_help_full(
|
||||
const Verb verbs[],
|
||||
const Verb verbs_end[],
|
||||
|
||||
@@ -140,6 +140,8 @@ 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)
|
||||
|
||||
void help_section(const char *title);
|
||||
|
||||
#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")
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "device-private.h"
|
||||
#include "device-util.h"
|
||||
#include "help-util.h"
|
||||
#include "log.h"
|
||||
#include "options.h"
|
||||
#include "udev-builtin.h"
|
||||
|
||||
Reference in New Issue
Block a user