New sync_args function

Change-Id: Ie1ed4cb5d13112957b156e6a9db7662ebc90f9a3
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/lib/gen_arg.py b/lib/gen_arg.py
index f176c65..c1c9af3 100755
--- a/lib/gen_arg.py
+++ b/lib/gen_arg.py
@@ -206,6 +206,26 @@
     return buffer
 
 
+def sync_args():
+    r"""
+    Synchronize the argument values to match their corresponding global variable values.
+
+    The user's validate_parms() function may manipulate global variables that correspond to program
+    arguments.  After validate_parms() is called, sync_args is called to set the altered values back into the
+    arg_obj.  This will ensure that the print-out of program arguments reflects the updated values.
+
+    Example:
+
+    def validate_parms():
+
+        # Set a default value for dir_path argument.
+        dir_path = gm.add_trailing_slash(gm.dft(dir_path, os.getcwd()))
+    """
+    module = sys.modules['__main__']
+    for key in arg_obj.__dict__:
+        arg_obj.__dict__[key] = getattr(module, key)
+
+
 term_options = None
 
 
@@ -491,6 +511,7 @@
 
     if validate_parms:
         validate_parms()
+        sync_args()
     gen_post_validation()
 
     gp.qprint_pgm_header()