From adac0113c5690599ce2f247d7a6eceba103b22a3 Mon Sep 17 00:00:00 2001
From: Darko Poljak <darko.poljak@gmail.com>
Date: Mon, 15 Aug 2016 16:37:38 +0200
Subject: [PATCH] Order options lexicographicaly.

---
 docs/src/man1/cdist.rst | 26 +++++++++++++-------------
 scripts/cdist           | 24 +++++++++++-------------
 2 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/docs/src/man1/cdist.rst b/docs/src/man1/cdist.rst
index 1eb57c12..a00a3ec0 100644
--- a/docs/src/man1/cdist.rst
+++ b/docs/src/man1/cdist.rst
@@ -15,9 +15,9 @@ SYNOPSIS
 
     cdist banner [-h] [-d] [-v]
 
-    cdist config [-h] [-d] [-v] [-c CONF_DIR] [-f HOSTFILE] [-i MANIFEST]
-                 [-n] [-o OUT_PATH] [-p] [-s] [--remote-copy REMOTE_COPY]
-                 [--remote-exec REMOTE_EXEC] [-j [JOBS]] [-b]
+    cdist config [-h] [-d] [-v] [-b] [-c CONF_DIR] [-f HOSTFILE]
+                 [-i MANIFEST] [-j [JOBS]] [-n] [-o OUT_PATH] [-p] [-s]
+                 [--remote-copy REMOTE_COPY] [--remote-exec REMOTE_EXEC]
                  [host [host ...]]
 
     cdist shell [-h] [-d] [-v] [-s SHELL]
@@ -62,6 +62,11 @@ CONFIG
 ------
 Configure one or more hosts.
 
+.. option:: -b, --enable-beta
+
+    Enable beta functionalities. Beta functionalities include the
+    following options: -j/--jobs.
+
 .. option:: -c CONF_DIR, --conf-dir CONF_DIR
 
     Add a configuration directory. Can be specified multiple times.
@@ -83,6 +88,11 @@ Configure one or more hosts.
 
     Path to a cdist manifest or - to read from stdin
 
+.. option:: -j [JOBS], --jobs [JOBS]
+
+    Specify the maximum number of parallel jobs; currently only
+    global explorers are supported (currently in beta)
+
 .. option:: -n, --dry-run
 
     Do not execute code
@@ -107,16 +117,6 @@ Configure one or more hosts.
 
     Command to use for remote execution (should behave like ssh)
 
-.. option:: -j [JOBS], --jobs [JOBS]
-
-    Specify the maximum number of parallel jobs; currently only
-    global explorers are supported (currently in beta)
-
-.. option:: -b, --enable-beta
-
-    Enable beta functionalities. Beta functionalities include the
-    following options: -j/--jobs.
-
 SHELL
 -----
 This command allows you to spawn a shell that enables access
diff --git a/scripts/cdist b/scripts/cdist
index a2f5fbfb..d02f0a5f 100755
--- a/scripts/cdist
+++ b/scripts/cdist
@@ -48,8 +48,6 @@ def check_beta(args_dict):
     # Check only if beta is not enabled: if beta option is specified then
     # raise error.
     if not args_dict['beta']:
-        err_msg = ("\'{}\' is beta, but beta is not enabled. If you want "
-                   "to use it please enable beta functionalities.")
         cmd = args_dict['command']
         for arg in BETA_ARGS[cmd]:
             if arg in args_dict:
@@ -97,6 +95,11 @@ def commandline():
             'config', parents=[parser['loglevel']])
     parser['config'].add_argument(
             'host', nargs='*', help='host(s) to operate on')
+    parser['config'].add_argument(
+           '-b', '--enable-beta',
+           help=('Enable beta functionalities. Beta functionalities '
+                 'include the following options: -j/--jobs.'),
+           action='store_true', dest='beta', default=False)
     parser['config'].add_argument(
             '-c', '--conf-dir',
             help=('Add configuration directory (can be repeated, '
@@ -112,6 +115,12 @@ def commandline():
            '-i', '--initial-manifest',
            help='Path to a cdist manifest or \'-\' to read from stdin.',
            dest='manifest', required=False)
+    parser['config'].add_argument(
+           '-j', '--jobs', nargs='?', type=check_positive_int,
+           help=('Specify the maximum number of parallel jobs, currently '
+                 'only global explorers are supported (currently in beta'),
+           action='store', dest='jobs',
+           const=multiprocessing.cpu_count())
     parser['config'].add_argument(
            '-n', '--dry-run',
            help='Do not execute code', action='store_true')
@@ -140,17 +149,6 @@ def commandline():
                  '(should behave like ssh)'),
            action='store', dest='remote_exec',
            default=os.environ.get('CDIST_REMOTE_EXEC'))
-    parser['config'].add_argument(
-           '-j', '--jobs', nargs='?', type=check_positive_int,
-           help=('Specify the maximum number of parallel jobs, currently '
-                 'only global explorers are supported (currently in beta'),
-           action='store', dest='jobs',
-           const=multiprocessing.cpu_count())
-    parser['config'].add_argument(
-           '-b', '--enable-beta',
-           help=('Enable beta functionalities. Beta functionalities '
-                 'include the following options: -j/--jobs.'),
-           action='store_true', dest='beta', default=False)
     parser['config'].set_defaults(func=cdist.config.Config.commandline)
 
     # Shell