From 1a1c02b11d7b533ca9a59813ec1746a949338325 Mon Sep 17 00:00:00 2001 From: Lon Hohberger Date: Tue, 12 Jan 2010 17:17:46 -0500 Subject: [PATCH] Fix up help text for clients * Output defaults from includes rather than static text * Add simple wrapping functions for help text Signed-off-by: Lon Hohberger --- client/options.c | 69 ++++++++++++++++++++++++++++++++++++++------- config/example.conf | 2 +- 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/client/options.c b/client/options.c index 4e7111c..6816ec2 100644 --- a/client/options.c +++ b/client/options.c @@ -308,7 +308,7 @@ static struct arg_info _arg_info[] = { NULL }, { 'd', "-d", "debug", - "Specify (CCS) / increment (command line) debug level", + "Specify (stdin) or increment (command line) debug level", assign_debug }, { 'i', "-i ", "ip_family", @@ -316,7 +316,7 @@ static struct arg_info _arg_info[] = { assign_family }, { 'a', "-a
", "multicast_address", - "Multicast address (default=225.0.0.12 / ff02::3:1)", + "Multicast address (default=" IPV4_MCAST_DEFAULT " / " IPV6_MCAST_DEFAULT ")", assign_address }, { 'p', "-p ", "port", @@ -340,7 +340,7 @@ static struct arg_info _arg_info[] = { assign_auth }, { 'k', "-k ", "key_file", - "Shared key file (default=/etc/cluster/fence_virt.key)", + "Shared key file (default=" DEFAULT_KEY_FILE ")", assign_key }, { 'D', "-D ", "serial_device", @@ -353,11 +353,11 @@ static struct arg_info _arg_info[] = { { '\xff', NULL, "option", /* Deprecated */ - "Fencing option (null, off, [reboot], status, devstatus)", + "Fencing option (null, off, on, [reboot], status, hostlist, devstatus)", assign_op }, { 'o', "-o ", "action", - "Fencing action (null, off, [reboot], status, devstatus)", + "Fencing action (null, off, on, [reboot], status, hostlist, devstatus)", assign_op }, { 'H', "-H ", "domain", @@ -365,7 +365,7 @@ static struct arg_info _arg_info[] = { assign_domain }, { 'u', "-u", "use_uuid", - "Treat as UUID instead of domain name", + "Treat as UUID instead of domain name. This is provided for compatibility with older fence_xvmd installations.", assign_uuid_lookup }, { 't', "-t ", "timeout", @@ -492,6 +492,57 @@ args_print(fence_virt_args_t *args) @param print_stdin 0 = print command line options + description, 1 = print fence-style stdin args + description */ +static char * +find_rev(const char *start, char *curr, char c) +{ + + while (curr > start) { + if (*curr == c) + return curr; + --curr; + } + + return NULL; +} + + +static void +output_help_text(int arg_width, int help_width, const char *arg, const char *desc) +{ + char out_buf[4096]; + char *p, *start; + const char *arg_print = arg; + int len; + + memset(out_buf, 0, sizeof(out_buf)); + strncpy(out_buf, desc, sizeof(out_buf)); + start = out_buf; + + do { + p = NULL; + len = strlen(start); + if (len > help_width) { + p = start + help_width; + p = find_rev(start, p, ' '); + if (p) { + *p = 0; + p++; + } + } + printf(" %*.*s %*.*s\n", + -arg_width, arg_width, + arg_print, + -help_width, help_width, + start); + if (!p) + return; + if (arg == arg_print) + arg_print = " "; + start = p; + } while(1); +} + + void args_usage(char *progname, const char *optstr, int print_stdin) { @@ -513,11 +564,9 @@ args_usage(char *progname, const char *optstr, int print_stdin) if (print_stdin) { if (arg && arg->stdin_opt) - printf(" %-20.20s %-55.55s\n", - arg->stdin_opt, arg->desc); + output_help_text(20, 55, arg->stdin_opt, arg->desc); } else { - printf(" %-20.20s %-55.55s\n", arg->opt_desc, - arg->desc); + output_help_text(20, 55, arg->opt_desc, arg->desc); } } diff --git a/config/example.conf b/config/example.conf index ec16ec9..ab9012a 100644 --- a/config/example.conf +++ b/config/example.conf @@ -6,7 +6,7 @@ fence_virtd { listeners { multicast { key_file = "/etc/cluster/fence_xvm.key"; - address = "225.0.0.14"; + address = "225.0.0.12"; } }