changeset 7380:bc60e907f73d

make-config: reorganize code to make it clear that --show-defaults can't be combined with custom key=value The key=value arguments could only be specified after specifying an ini file, and that couldn't be combined with --show-defaults.
author Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
date Mon, 24 Sep 2018 22:37:44 +0200
parents a38e889683bc
children b8deb93894ea
files kallithea/lib/paster_commands/make_config.py
diffstat 1 files changed, 10 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/paster_commands/make_config.py	Mon Sep 24 22:37:44 2018 +0200
+++ b/kallithea/lib/paster_commands/make_config.py	Mon Sep 24 22:37:44 2018 +0200
@@ -41,8 +41,8 @@
     file (possibly filling in defaults from the extra
     variables you give).
 
-    The first key=value arguments are used to customize the Mako variables that
-    are shown with --show-defaults. The following settings will be
+    The first key=value arguments are used to customize the Mako variables from
+    what is shown with --show-defaults. Any following key=value arguments will be
     patched/inserted in the [app:main] section ... until another section name
     is specified and change where the following values go.
     """
@@ -59,7 +59,7 @@
             help='application config file to write')
 
         parser.add_argument('custom', nargs=argparse.REMAINDER,
-            help='custom values for the config file')
+            help='"key=value" for customizing the config file')
 
         parser.add_argument('--show-defaults', action='store_true',
             help="Show the default values that can be overridden")
@@ -68,12 +68,14 @@
 
 
 def _run(args):
+    if args.show_defaults:
+        if args.config_file is not None:
+            raise ValueError("Can't specify both config file and --show-defaults")
+        for key, value in inifile.default_variables.items():
+            print '%s=%s' % (key, value)
+        sys.exit(0)
     if args.config_file is None:
-        if not args.show_defaults:
-            raise ValueError("Missing argument: config_file")
-    else:
-        if args.show_defaults:
-            raise ValueError("Can't specify both config_file and --show_defaults")
+        raise ValueError("Missing argument: config file")
 
     mako_variable_values = {}
     ini_settings = defaultdict(dict)
@@ -94,12 +96,6 @@
         else:
             raise ValueError("Invalid name=value parameter %r" % parameter)
 
-    if args.show_defaults:
-        for key, value in inifile.default_variables.items():
-            value = mako_variable_values.get(key, value)
-            print '%s=%s' % (key, value)
-        sys.exit(0)
-
     # use default that cannot be replaced
     mako_variable_values.update({
         'uuid': lambda: uuid.uuid4().hex,