verbs: add flags and allow verbs&options tables to not be synchronized

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-13 13:23:05 +02:00
parent 7e2ef99cfb
commit e256153186
2 changed files with 12 additions and 1 deletions
+7 -1
View File
@@ -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]))
+5
View File
@@ -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 {