]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: supply long option for -V
authorEric Blake <eblake@redhat.com>
Tue, 9 Nov 2010 20:44:47 +0000 (13:44 -0700)
committerEric Blake <eblake@redhat.com>
Wed, 10 Nov 2010 23:57:40 +0000 (16:57 -0700)
* tools/virsh.c (vshParseArgv): Use NULL instead of 0 for pointer,
and symbolic names for has_arg.  Give --version an optional arg.
(vshUsage): Document this.
* tools/virsh.pod: Likewise.

tools/virsh.c
tools/virsh.pod

index 0c91f15d4ae2ab141319c589ca60c12ad0704231..cd20d34d9c8cd2cd165515b5136ea36ac772e827 100644 (file)
@@ -11523,8 +11523,8 @@ vshUsage(void)
                       "    -q | --quiet            quiet mode\n"
                       "    -t | --timing           print timing information\n"
                       "    -l | --log <file>       output logging to file\n"
-                      "    -v | --version          program version\n\n"
-                      "    -V                      version and full options\n\n"
+                      "    -v | --version[=short]  program version\n\n"
+                      "    -V | --version=long     version and full options\n\n"
                       "  commands (non interactive mode):\n"), progname, progname);
 
     for (cmd = commands; cmd->name; cmd++)
@@ -11669,15 +11669,15 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
     bool help = false;
     int arg;
     struct option opt[] = {
-        {"debug", 1, 0, 'd'},
-        {"help", 0, 0, 'h'},
-        {"quiet", 0, 0, 'q'},
-        {"timing", 0, 0, 't'},
-        {"version", 0, 0, 'v'},
-        {"connect", 1, 0, 'c'},
-        {"readonly", 0, 0, 'r'},
-        {"log", 1, 0, 'l'},
-        {0, 0, 0, 0}
+        {"debug", required_argument, NULL, 'd'},
+        {"help", no_argument, NULL, 'h'},
+        {"quiet", no_argument, NULL, 'q'},
+        {"timing", no_argument, NULL, 't'},
+        {"version", optional_argument, NULL, 'v'},
+        {"connect", required_argument, NULL, 'c'},
+        {"readonly", no_argument, NULL, 'r'},
+        {"log", required_argument, NULL, 'l'},
+        {NULL, 0, NULL, 0}
     };
 
     /* Standard (non-command) options. The leading + ensures that no
@@ -11703,12 +11703,15 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
         case 'c':
             ctl->name = vshStrdup(ctl, optarg);
             break;
+        case 'v':
+            if (STRNEQ_NULLABLE(optarg, "long")) {
+                puts(VERSION);
+                exit(EXIT_SUCCESS);
+            }
+            /* fall through */
         case 'V':
             vshShowVersion(ctl);
             exit(EXIT_SUCCESS);
-        case 'v':
-            puts(VERSION);
-            exit(EXIT_SUCCESS);
         case 'r':
             ctl->readonly = TRUE;
             break;
index 4f3f220f7c64d5dcb1fc79bb6563c4817de4e7b0..1646a614365463642fe21b82b2ab8d45953e9845 100644 (file)
@@ -54,12 +54,12 @@ The B<virsh> program understands the following I<OPTIONS>.
 Ignore all other arguments, and behave as if the B<help> command were
 given instead.
 
-=item B<-v>, B<--version>
+=item B<-v>, B<--version[=short]>
 
 Ignore all other arguments, and prints the version of the libvirt library
 virsh is coming from
 
-=item B<-V>
+=item B<-V>, B<--version=long>
 
 Ignore all other arguments, and prints the version of the libvirt library
 virsh is coming from and which options and driver are compiled in.