From 9088095164ebdac098b954d668cce3a685c051c2 Mon Sep 17 00:00:00 2001
From: Tiago Freitas Pereira <tiagofrepereira@gmail.com>
Date: Mon, 27 Feb 2017 09:52:23 +0100
Subject: [PATCH] Created 2 classes of arguments (mandatory and optional)

---
 bob/bio/base/tools/command_line.py | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/bob/bio/base/tools/command_line.py b/bob/bio/base/tools/command_line.py
index 31af638b..f38b2124 100644
--- a/bob/bio/base/tools/command_line.py
+++ b/bob/bio/base/tools/command_line.py
@@ -451,17 +451,31 @@ def _create_configuration_file(parsers, args):
 
   parser = parsers['main']
 
+  #import ipdb; ipdb.set_trace();
+
   bob.io.base.create_directories_safe(os.path.dirname(args.create_configuration_file))
+
+  arguments = "# Configuration file automatically generated at %s for %s\n\n" % (datetime.date.today(), executables[0])
+  optional_arguments = "################################################## \n############### OPTIONAL ARGUMENTS ############### \n##################################################n\n\n"  
+  
   with open(args.create_configuration_file, 'w') as f:
-    f.write("# Configuration file automatically generated at %s for %s\n\n" % (datetime.date.today(), executables[0]))
 
     for action in parser._actions[3:]:
       if action.help == "==SUPPRESS==":
         continue
-      f.write("# %s\n\n" % action.help)
+        
+      tmp_arguments = "# %s\n\n" % action.help
       if action.nargs is None and action.type is None and action.default is not None:
-        f.write("#%s = '%s'\n\n\n" % (action.dest, action.default))
+        tmp_arguments +=  "#%s = '%s'\n\n\n" % (action.dest, action.default)
       else:
-        f.write("#%s = %s\n\n\n" % (action.dest, action.default))
+        tmp_arguments += "#%s = %s\n\n\n" % (action.dest, action.default)
+
+      if action.metavar == "x":
+        arguments += tmp_arguments
+      else:
+        optional_arguments += tmp_arguments
+
+    f.write(arguments)
+    f.write(optional_arguments)
 
   parser.exit(1, "Configuration file '%s' was written; exiting\n" % args.create_configuration_file)
-- 
GitLab