From 81f23192917cf5b6a5ec5c4fde72ffac4440fb73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 15 Aug 2026 12:50:17 +0200 Subject: [PATCH] delta: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. --help now goes through the pager, like other commands with --no-pager. --- src/delta/delta.c | 45 +++++++------------ .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/src/delta/delta.c b/src/delta/delta.c index 27dfc105ee..22db51c793 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -2,30 +2,31 @@ #include +#include "sd-json.h" + #include "alloc-util.h" +#include "ansi-color.h" #include "build.h" #include "chase.h" #include "dirent-util.h" #include "errno-util.h" #include "extract-word.h" #include "fd-util.h" -#include "format-table.h" #include "fs-util.h" #include "glyph-util.h" #include "hashmap.h" #include "log.h" #include "main-func.h" #include "nulstr-util.h" -#include "options.h" #include "pager.h" #include "parse-argument.h" #include "path-util.h" #include "pidref.h" -#include "pretty-print.h" #include "process-util.h" #include "stat-util.h" #include "string-util.h" #include "strv.h" +#include "verbs.h" static const char prefixes[] = "/etc\0" @@ -67,6 +68,14 @@ static enum { (SHOW_MASKED | SHOW_EQUIVALENT | SHOW_REDIRECTED | SHOW_OVERRIDDEN | SHOW_EXTENDED) } arg_flags = 0; +COMMAND( + "systemd-delta\0", + "Find overridden configuration files.", + .argspec = "[SUFFIX…]\0", + .man_pages = "systemd-delta.1\0", + .pager_flags = &arg_pager_flags, +); + static int equivalent(const char *a, const char *b) { _cleanup_free_ char *x = NULL, *y = NULL; int r; @@ -458,31 +467,6 @@ static int process_suffix_chop(const char *arg) { "Invalid suffix specification %s.", arg); } -static int help(void) { - _cleanup_free_ char *link = NULL; - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = terminal_urlify_man("systemd-delta", "1", &link); - if (r < 0) - return log_oom(); - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - printf("%s [OPTIONS...] [SUFFIX...]\n\n" - "Find overridden configuration files.\n\n", - program_invocation_short_name); - - r = table_print_or_warn(options); - if (r < 0) - return r; - - printf("\nSee the %s for details.\n", link); - return 0; -} - static int parse_flags(const char *flag_str, int flags) { for (;;) { _cleanup_free_ char *word = NULL; @@ -524,7 +508,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-delta"); OPTION_COMMON_VERSION: return version(); @@ -548,6 +532,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { return r; arg_diff = r; break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } *ret_args = option_parser_get_args(&opts); diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index 67d62cadba..e1e678a86b 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -21,6 +21,7 @@ INTROSPECTABLE=( systemd-cat systemd-cgls systemd-cgtop + systemd-delta systemd-dissect systemd-firstboot systemd-hwdb