From e256153186f98a05fa470ecc4bc91b34ec827078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 24 Jul 2026 16:32:27 +0200 Subject: [PATCH] verbs: add flags and allow verbs&options tables to not be synchronized --- src/shared/verbs.c | 8 +++++++- src/shared/verbs.h | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/shared/verbs.c b/src/shared/verbs.c index 726ed30ac2..cc0b358fcd 100644 --- a/src/shared/verbs.c +++ b/src/shared/verbs.c @@ -347,6 +347,9 @@ static int print_verb_option_help( verb += r; /* Skip over the whole verb group */ } + if (cmd->flags & COMMAND_HELP_SEPARATE) + (void) table_sync_all_column_widths(0, tables); + const Option *optns = options_find_namespace(options, options_end, cmd->option_namespace); if (!optns) return log_error_errno(SYNTHETIC_ERRNO(EUCLEAN), @@ -376,7 +379,10 @@ static int print_verb_option_help( opt += r; /* Skip over the whole option group */ } - (void) table_sync_all_column_widths(0, tables); + if (cmd->flags & COMMAND_HELP_SEPARATE) + (void) table_sync_all_column_widths(0, tables + n_verbs); + else + (void) table_sync_all_column_widths(0, tables); for (size_t i = 0; i < n_verbs + n_opts; i++) { if (table_isempty(tables[i])) diff --git a/src/shared/verbs.h b/src/shared/verbs.h index 59fb8a3951..52b3cfd9ba 100644 --- a/src/shared/verbs.h +++ b/src/shared/verbs.h @@ -6,6 +6,10 @@ #define VERB_ANY (UINT_MAX) +typedef enum CommandFlags { + COMMAND_HELP_SEPARATE = 1 << 0, /* Do not synchronize the width between verbs and options */ +} CommandFlags; + typedef struct CommandDescription { const char *names; /* nulstr with the main command name and potentially aliases */ const char *abstract; /* concrete abstract */ @@ -13,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 */ + CommandFlags flags; } CommandDescription; typedef enum VerbFlags {