提交 51c83a2b 编写于 作者: E Eric Blake

virsh: supply long option for -V

* 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.
上级 96d52fcf
...@@ -11523,8 +11523,8 @@ vshUsage(void) ...@@ -11523,8 +11523,8 @@ vshUsage(void)
" -q | --quiet quiet mode\n" " -q | --quiet quiet mode\n"
" -t | --timing print timing information\n" " -t | --timing print timing information\n"
" -l | --log <file> output logging to file\n" " -l | --log <file> output logging to file\n"
" -v | --version program version\n\n" " -v | --version[=short] program version\n\n"
" -V version and full options\n\n" " -V | --version=long version and full options\n\n"
" commands (non interactive mode):\n"), progname, progname); " commands (non interactive mode):\n"), progname, progname);
for (cmd = commands; cmd->name; cmd++) for (cmd = commands; cmd->name; cmd++)
...@@ -11669,15 +11669,15 @@ vshParseArgv(vshControl *ctl, int argc, char **argv) ...@@ -11669,15 +11669,15 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
bool help = false; bool help = false;
int arg; int arg;
struct option opt[] = { struct option opt[] = {
{"debug", 1, 0, 'd'}, {"debug", required_argument, NULL, 'd'},
{"help", 0, 0, 'h'}, {"help", no_argument, NULL, 'h'},
{"quiet", 0, 0, 'q'}, {"quiet", no_argument, NULL, 'q'},
{"timing", 0, 0, 't'}, {"timing", no_argument, NULL, 't'},
{"version", 0, 0, 'v'}, {"version", optional_argument, NULL, 'v'},
{"connect", 1, 0, 'c'}, {"connect", required_argument, NULL, 'c'},
{"readonly", 0, 0, 'r'}, {"readonly", no_argument, NULL, 'r'},
{"log", 1, 0, 'l'}, {"log", required_argument, NULL, 'l'},
{0, 0, 0, 0} {NULL, 0, NULL, 0}
}; };
/* Standard (non-command) options. The leading + ensures that no /* Standard (non-command) options. The leading + ensures that no
...@@ -11703,12 +11703,15 @@ vshParseArgv(vshControl *ctl, int argc, char **argv) ...@@ -11703,12 +11703,15 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
case 'c': case 'c':
ctl->name = vshStrdup(ctl, optarg); ctl->name = vshStrdup(ctl, optarg);
break; break;
case 'v':
if (STRNEQ_NULLABLE(optarg, "long")) {
puts(VERSION);
exit(EXIT_SUCCESS);
}
/* fall through */
case 'V': case 'V':
vshShowVersion(ctl); vshShowVersion(ctl);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
case 'v':
puts(VERSION);
exit(EXIT_SUCCESS);
case 'r': case 'r':
ctl->readonly = TRUE; ctl->readonly = TRUE;
break; break;
......
...@@ -54,12 +54,12 @@ The B<virsh> program understands the following I<OPTIONS>. ...@@ -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 Ignore all other arguments, and behave as if the B<help> command were
given instead. 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 Ignore all other arguments, and prints the version of the libvirt library
virsh is coming from 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 Ignore all other arguments, and prints the version of the libvirt library
virsh is coming from and which options and driver are compiled in. virsh is coming from and which options and driver are compiled in.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册