[virt-tools-list] [vhostmd] Fix help option

Jim Fehlig jfehlig at suse.com
Wed Jun 20 22:40:58 UTC 2018


Fix the short option for help, add help to the help output, and
add help to the vhostmd man page.

Signed-off-by: Jim Fehlig <jfehlig at suse.com>
---
 docs/man/vhostmd.8 | 3 +++
 vhostmd/vhostmd.c  | 7 ++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/docs/man/vhostmd.8 b/docs/man/vhostmd.8
index 2c73adc..ed82432 100644
--- a/docs/man/vhostmd.8
+++ b/docs/man/vhostmd.8
@@ -13,6 +13,9 @@ provides a "metrics communication channel" between a host and its hosted virtual
 vhostmd will periodically write metrics to a disk.  The metrics to write, how often, and where to write them are all adjustable via the /etc/vhostmd/vhostmd.conf configuration file.  The disk can then be surfaced read-only to virtual machines using tools provided by the host's virtualization platform.
 .SH OPTIONS
 .TP
+.B \-h, --help
+Display help and exit
+.TP
 .B \-v, --verbose
 Verbose messages
 .TP
diff --git a/vhostmd/vhostmd.c b/vhostmd/vhostmd.c
index 7f04705..8576609 100644
--- a/vhostmd/vhostmd.c
+++ b/vhostmd/vhostmd.c
@@ -950,6 +950,7 @@ static void usage(const char *argv0)
    %s [options]\n\
    \n\
    Options:\n\
+   -h | --help            Display program help.\n\
    -v | --verbose         Verbose messages.\n\
    -c | --connect <uri>   Set the libvirt URI.\n\
    -d | --no-daemonize    Process will not daemonize - useful for debugging.\n\
@@ -980,7 +981,7 @@ int main(int argc, char *argv[])
       { "pid-file", required_argument, NULL, 'p'},
       { "user", required_argument, NULL, 'u'},
       { "connect", required_argument, NULL, 'c'},
-      { "help", no_argument, NULL, '?' },
+      { "help", no_argument, NULL, 'h' },
       {0, 0, 0, 0}
    };
 
@@ -988,7 +989,7 @@ int main(int argc, char *argv[])
       int optidx = 0;
       int c;
 
-      c = getopt_long(argc, argv, "c:df:p:u:v", opts, &optidx);
+      c = getopt_long(argc, argv, "c:df:p:u:vh", opts, &optidx);
 
       if (c == -1)
          break;
@@ -1015,7 +1016,7 @@ int main(int argc, char *argv[])
          case 'c':
 	    libvirt_uri = optarg;
 	    break;
-         case '?':
+         case 'h':
             usage(argv[0]);
             return 2;
          default:
-- 
2.17.1




More information about the virt-tools-list mailing list