verbs: add PagerFlags pointer to all CommandDescription's

Before this series, many help() functions opened the pager. This got lost
in the translation. Starting the pager requires access to arg_pager_flags.
While we could pipe this through in case when command_print_help() is
called directly, but this hard in the case when verb_help_auto() or
VERB_COMMON_HELP_AUTO/VERB_COMMON_HELP_AUTO_HIDDEN are used. Let's instead
extend the (const static) CommandDescription structure with a pointer to
the arg_pager_flags variable. This restores the pager functionality in a
uniform fashion with a one-line change in the individual binaries.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-13 13:46:08 +02:00
parent 8a14181f55
commit 7670c20c6e
9 changed files with 13 additions and 0 deletions
+1
View File
@@ -200,6 +200,7 @@ COMMAND(
"systemd-analyze\0",
.abstract = "Profile systemd, show unit dependencies, check unit files.",
.man_pages = "systemd-analyze.1\0",
.pager_flags = &arg_pager_flags,
);
VERB_COMMON_HELP_AUTO_HIDDEN("systemd-analyze");
+1
View File
@@ -141,6 +141,7 @@ COMMAND(
"--shift IMAGE UIDBASE\0",
.man_pages = "systemd-dissect.1\0",
.option_namespace = "systemd-dissect",
.pager_flags = &arg_pager_flags,
);
static int parse_image_path_argument(const char *path, char **ret_root, char **ret_image) {
+1
View File
@@ -183,6 +183,7 @@ COMMAND(
"homectl\0",
"Create, manipulate or inspect home directories.",
.man_pages = "homectl.1\0",
.pager_flags = &arg_pager_flags,
.flags = COMMAND_HELP_SEPARATE, /* the option table is very wide */
);
+1
View File
@@ -29,6 +29,7 @@ COMMAND(
"systemd-id128\0",
"Generate and print 128-bit identifiers.",
.man_pages = "systemd-id128.1\0",
.pager_flags = &arg_pager_flags,
);
static int print_id(sd_id128_t id) {
+2
View File
@@ -101,6 +101,7 @@ COMMAND(
"resolve domain names, IPv4 and IPv6 addresses, DNS records, and services.",
.man_pages = "resolvectl.1\0",
.option_namespace = "resolvectl",
.pager_flags = &arg_pager_flags,
);
typedef enum StatusMode {
@@ -3225,6 +3226,7 @@ COMMAND(
"This command is deprecated. Use resolvectl.1 instead.",
.man_pages = "resolvectl.1\0",
.option_namespace = "systemd-resolve",
.pager_flags = &arg_pager_flags,
);
static int compat_parse_argv(int argc, char *argv[], char ***remaining_args) {
+4
View File
@@ -9,6 +9,7 @@
#include "log.h"
#include "nulstr-util.h"
#include "options.h"
#include "pager.h"
#include "pretty-print.h"
#include "string-util.h"
#include "strv.h"
@@ -444,6 +445,9 @@ int _command_print_help(
const CommandDescription *cmd = (const CommandDescription*) ASSERT_PTR(cmdverb->data);
if (cmd->pager_flags)
pager_open(*cmd->pager_flags);
if (cmd->argspec)
NULSTR_FOREACH(spec, cmd->argspec) {
_cleanup_free_ char *line = strjoin("[OPTION…] ", spec);
+1
View File
@@ -17,6 +17,7 @@ typedef struct CommandDescription {
const char *footer; /* optional footer to print right above man page links */
const char *man_pages; /* nulstr with man page names */
const char *option_namespace; /* to be used when the options are in a namespace */
const PagerFlags *pager_flags; /* optional pointer to the runtime pager flags variable */
CommandFlags flags;
} CommandDescription;
+1
View File
@@ -183,6 +183,7 @@ COMMAND(
"timedatectl\0",
.abstract = "Query or change system time and date settings.",
.man_pages = "timedatectl.1\0",
.pager_flags = &arg_pager_flags,
);
VERB_DEFAULT_NOARG(verb_status, "status", "Show current time settings");
+1
View File
@@ -292,6 +292,7 @@ COMMAND(
.man_pages = "varlinkctl.1\0",
.footer = "With --exec, specify the command to invoke:\n"
" varlinkctl --exec call ADDRESS METHOD PARAMS -- CMDLINE…",
.pager_flags = &arg_pager_flags,
);
VERB(verb_info, "info", "ADDRESS", 2, 2, 0, "Show service information");