mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35:20 +00:00
virsh: Sort options alphabetically
Man page, help output and also parsing is sorted in order to find options smoothly. Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
8922c3d07a
commit
fb235130fe
@ -3110,16 +3110,16 @@ vshUsage(void)
|
||||
"\n%s [options]... <command> [args...]\n\n"
|
||||
" options:\n"
|
||||
" -c | --connect=URI hypervisor connection URI\n"
|
||||
" -r | --readonly connect readonly\n"
|
||||
" -d | --debug=NUM debug level [0-4]\n"
|
||||
" -e | --escape <char> set escape sequence for console\n"
|
||||
" -h | --help this help\n"
|
||||
" -q | --quiet quiet mode\n"
|
||||
" -t | --timing print timing information\n"
|
||||
" -l | --log=FILE output logging to file\n"
|
||||
" -q | --quiet quiet mode\n"
|
||||
" -r | --readonly connect readonly\n"
|
||||
" -t | --timing print timing information\n"
|
||||
" -v short version\n"
|
||||
" -V long version\n"
|
||||
" --version[=TYPE] version, TYPE is short or long (default short)\n"
|
||||
" -e | --escape <char> set escape sequence for console\n\n"
|
||||
" commands (non interactive mode):\n\n"), progname, progname);
|
||||
|
||||
for (grp = cmdGroups; grp->name; grp++) {
|
||||
@ -3306,23 +3306,27 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
|
||||
size_t i;
|
||||
int longindex = -1;
|
||||
struct option opt[] = {
|
||||
{"connect", required_argument, NULL, 'c'},
|
||||
{"debug", required_argument, NULL, 'd'},
|
||||
{"escape", required_argument, NULL, 'e'},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"log", required_argument, NULL, 'l'},
|
||||
{"quiet", no_argument, NULL, 'q'},
|
||||
{"readonly", no_argument, NULL, 'r'},
|
||||
{"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'},
|
||||
{"escape", required_argument, NULL, 'e'},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
/* Standard (non-command) options. The leading + ensures that no
|
||||
* argument reordering takes place, so that command options are
|
||||
* not confused with top-level virsh options. */
|
||||
while ((arg = getopt_long(argc, argv, "+:d:hqtc:vVrl:e:", opt, &longindex)) != -1) {
|
||||
while ((arg = getopt_long(argc, argv, "+:c:d:e:hl:qrtvV", opt, &longindex)) != -1) {
|
||||
switch (arg) {
|
||||
case 'c':
|
||||
VIR_FREE(ctl->name);
|
||||
ctl->name = vshStrdup(ctl, optarg);
|
||||
break;
|
||||
case 'd':
|
||||
if (virStrToLong_i(optarg, NULL, 10, &debug) < 0) {
|
||||
vshError(ctl, _("option %s takes a numeric argument"),
|
||||
@ -3335,37 +3339,6 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
|
||||
else
|
||||
ctl->debug = debug;
|
||||
break;
|
||||
case 'h':
|
||||
vshUsage();
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'q':
|
||||
ctl->quiet = true;
|
||||
break;
|
||||
case 't':
|
||||
ctl->timing = true;
|
||||
break;
|
||||
case 'c':
|
||||
VIR_FREE(ctl->name);
|
||||
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 'r':
|
||||
ctl->readonly = true;
|
||||
break;
|
||||
case 'l':
|
||||
vshCloseLogFile(ctl);
|
||||
ctl->logfile = vshStrdup(ctl, optarg);
|
||||
vshOpenLogFile(ctl);
|
||||
break;
|
||||
case 'e':
|
||||
len = strlen(optarg);
|
||||
|
||||
@ -3379,6 +3352,33 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
vshUsage();
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'l':
|
||||
vshCloseLogFile(ctl);
|
||||
ctl->logfile = vshStrdup(ctl, optarg);
|
||||
vshOpenLogFile(ctl);
|
||||
break;
|
||||
case 'q':
|
||||
ctl->quiet = true;
|
||||
break;
|
||||
case 't':
|
||||
ctl->timing = true;
|
||||
break;
|
||||
case 'r':
|
||||
ctl->readonly = true;
|
||||
break;
|
||||
case 'v':
|
||||
if (STRNEQ_NULLABLE(optarg, "long")) {
|
||||
puts(VERSION);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
/* fall through */
|
||||
case 'V':
|
||||
vshShowVersion(ctl);
|
||||
exit(EXIT_SUCCESS);
|
||||
case ':':
|
||||
for (i = 0; opt[i].name != NULL; i++) {
|
||||
if (opt[i].val == optopt)
|
||||
|
@ -52,21 +52,6 @@ The B<virsh> program understands the following I<OPTIONS>.
|
||||
|
||||
=over 4
|
||||
|
||||
=item B<-h>, B<--help>
|
||||
|
||||
Ignore all other arguments, and behave as if the B<help> command were
|
||||
given instead.
|
||||
|
||||
=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>, 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.
|
||||
|
||||
=item B<-c>, B<--connect> I<URI>
|
||||
|
||||
Connect to the specified I<URI>, as if by the B<connect> command,
|
||||
@ -78,6 +63,17 @@ Enable debug messages at integer I<LEVEL> and above. I<LEVEL> can
|
||||
range from 0 to 4 (default). See the documentation of B<VIRSH_DEBUG>
|
||||
environment variable below for the description of each I<LEVEL>.
|
||||
|
||||
=item B<-e>, B<--escape> I<string>
|
||||
|
||||
Set alternative escape sequence for I<console> command. By default,
|
||||
telnet's B<^]> is used. Allowed characters when using hat notation are:
|
||||
alphabetic character, @, [, ], \, ^, _.
|
||||
|
||||
=item B<-h>, B<--help>
|
||||
|
||||
Ignore all other arguments, and behave as if the B<help> command were
|
||||
given instead.
|
||||
|
||||
=item B<-l>, B<--log> I<FILE>
|
||||
|
||||
Output logging details to I<FILE>.
|
||||
@ -95,11 +91,15 @@ option of the B<connect> command.
|
||||
|
||||
Output elapsed time information for each command.
|
||||
|
||||
=item B<-e>, B<--escape> I<string>
|
||||
=item B<-v>, B<--version[=short]>
|
||||
|
||||
Set alternative escape sequence for I<console> command. By default,
|
||||
telnet's B<^]> is used. Allowed characters when using hat notation are:
|
||||
alphabetic character, @, [, ], \, ^, _.
|
||||
Ignore all other arguments, and prints the version of the libvirt library
|
||||
virsh is coming from
|
||||
|
||||
=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.
|
||||
|
||||
=back
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user