[PATCH 1/4] virsh: Sort options alphabetically

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Man page, help output and also parsing is sorted in order to find
options smoothly.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 tools/virsh.c   | 64 ++++++++++++++++++++++++++++-----------------------------
 tools/virsh.pod | 38 +++++++++++++++++-----------------
 2 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 2d4aaff..9b8429f 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -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"
+                      "    -l | --log=FILE         output logging to file\n"
                       "    -q | --quiet            quiet mode\n"
+                      "    -r | --readonly         connect readonly\n"
                       "    -t | --timing           print timing information\n"
-                      "    -l | --log=FILE         output logging to file\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,19 +3339,36 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
             else
                 ctl->debug = debug;
             break;
+        case 'e':
+            len = strlen(optarg);
+
+            if ((len == 2 && *optarg == '^' &&
+                 vshAllowedEscapeChar(optarg[1])) ||
+                (len == 1 && *optarg != '^')) {
+                ctl->escapeChar = optarg;
+            } else {
+                vshError(ctl, _("Invalid string '%s' for escape sequence"),
+                         optarg);
+                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 'c':
-            VIR_FREE(ctl->name);
-            ctl->name = vshStrdup(ctl, optarg);
+        case 'r':
+            ctl->readonly = true;
             break;
         case 'v':
             if (STRNEQ_NULLABLE(optarg, "long")) {
@@ -3358,27 +3379,6 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
         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);
-
-            if ((len == 2 && *optarg == '^' &&
-                 vshAllowedEscapeChar(optarg[1])) ||
-                (len == 1 && *optarg != '^')) {
-                ctl->escapeChar = optarg;
-            } else {
-                vshError(ctl, _("Invalid string '%s' for escape sequence"),
-                         optarg);
-                exit(EXIT_FAILURE);
-            }
-            break;
         case ':':
             for (i = 0; opt[i].name != NULL; i++) {
                 if (opt[i].val == optopt)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index cafbb9a..cefce1b 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -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

-- 
1.9.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]