From 65064e2ff050fcf0daeefb4c1d03ba77c6b7f79b Mon Sep 17 00:00:00 2001 From: Antonio Alvarez Feijoo Date: Mon, 11 Mar 2024 13:34:34 +0100 Subject: [PATCH 1/2] tree-wide: drop custom formatting for print() help messages Follow-up for bc556335b1c568c98688cc1f586b5f753fcddac6 --- src/creds/creds.c | 13 +++++++------ src/shared/service-util.c | 14 ++++++++------ src/sysupdate/sysupdate.c | 13 +++++++------ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/creds/creds.c b/src/creds/creds.c index 02e317ad2d..4af5f28721 100644 --- a/src/creds/creds.c +++ b/src/creds/creds.c @@ -742,12 +742,13 @@ static int verb_help(int argc, char **argv, void *userdata) { " --user Select user-scoped credential encryption\n" " --uid=UID Select user for scoped credentials\n" " -q --quiet Suppress output for 'has-tpm2' verb\n" - "\nSee the %2$s for details.\n" - , program_invocation_short_name - , link - , ansi_underline(), ansi_normal() - , ansi_highlight(), ansi_normal() - ); + "\nSee the %2$s for details.\n", + program_invocation_short_name, + link, + ansi_underline(), + ansi_normal(), + ansi_highlight(), + ansi_normal()); return 0; } diff --git a/src/shared/service-util.c b/src/shared/service-util.c index b0585ba546..a415d54084 100644 --- a/src/shared/service-util.c +++ b/src/shared/service-util.c @@ -24,12 +24,14 @@ static int help(const char *program_path, const char *service, const char *descr " -h --help Show this help\n" " --version Show package version\n" " --bus-introspect=PATH Write D-Bus XML introspection data\n" - "\nSee the %s for details.\n" - , program_path - , ansi_highlight(), description, ansi_normal() - , ansi_underline(), ansi_normal() - , link - ); + "\nSee the %s for details.\n", + program_path, + ansi_highlight(), + description, + ansi_normal(), + ansi_underline(), + ansi_normal(), + link); return 0; /* No further action */ } diff --git a/src/sysupdate/sysupdate.c b/src/sysupdate/sysupdate.c index 2b88785e9f..b55383ee39 100644 --- a/src/sysupdate/sysupdate.c +++ b/src/sysupdate/sysupdate.c @@ -1221,12 +1221,13 @@ static int verb_help(int argc, char **argv, void *userdata) { " --no-legend Do not show the headers and footers\n" " --json=pretty|short|off\n" " Generate JSON output\n" - "\nSee the %2$s for details.\n" - , program_invocation_short_name - , link - , ansi_underline(), ansi_normal() - , ansi_highlight(), ansi_normal() - ); + "\nSee the %2$s for details.\n", + program_invocation_short_name, + link, + ansi_underline(), + ansi_normal(), + ansi_highlight(), + ansi_normal()); return 0; } From 4313b99136dcab00fd00624fdce2306562d8bf6f Mon Sep 17 00:00:00 2001 From: Antonio Alvarez Feijoo Date: Mon, 11 Mar 2024 13:56:30 +0100 Subject: [PATCH 2/2] shared/service-util: actually use the `bus_introspect` argument in `help()` If `bus_introspect` is false, do not print the `--bus-introspect=PATH` option. Also, modernize help output. --- src/shared/service-util.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/shared/service-util.c b/src/shared/service-util.c index a415d54084..7d46ee7a66 100644 --- a/src/shared/service-util.c +++ b/src/shared/service-util.c @@ -17,21 +17,22 @@ static int help(const char *program_path, const char *service, const char *descr if (r < 0) return log_oom(); - printf("%s [OPTIONS...]\n\n" - "%s%s%s\n\n" - "This program takes no positional arguments.\n\n" - "%sOptions%s:\n" + printf("%1$s [OPTIONS...]\n" + "\n%5$s%7$s%6$s\n" + "\nThis program takes no positional arguments.\n" + "\n%3$sOptions:%4$s\n" " -h --help Show this help\n" " --version Show package version\n" - " --bus-introspect=PATH Write D-Bus XML introspection data\n" - "\nSee the %s for details.\n", + "%8$s" + "\nSee the %2$s for details.\n", program_path, - ansi_highlight(), - description, - ansi_normal(), + link, ansi_underline(), ansi_normal(), - link); + ansi_highlight(), + ansi_normal(), + description, + bus_introspect ? " --bus-introspect=PATH Write D-Bus XML introspection data\n" : ""); return 0; /* No further action */ }