]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
qconfig: Move arg parsing into a separate function
authorSimon Glass <sjg@chromium.org>
Wed, 17 Jul 2024 15:56:55 +0000 (16:56 +0100)
committerSimon Glass <sjg@chromium.org>
Fri, 26 Jul 2024 14:01:06 +0000 (08:01 -0600)
Reduce the size of main() by putting this code into its own function.
For now the parser object needs to be returned too.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/qconfig.py

index 07d7838746503caabc7855ce8431c802490f971f..d8f0a716fe952d641151b8b5fc147a9a3612fe3e 100755 (executable)
@@ -1453,8 +1453,14 @@ def do_scan_source(path, do_update):
                 print(item, file=out)
 
 
-def main():
-    """Main program"""
+def parse_args():
+    """Parse the program arguments
+
+    Returns:
+        tuple:
+            argparse.ArgumentParser: parser
+            argparse.Namespace: Parsed arguments
+    """
     try:
         cpu_count = multiprocessing.cpu_count()
     except NotImplementedError:
@@ -1512,8 +1518,12 @@ doc/develop/moveconfig.rst for documentation.'''
                       help='show any build errors as boards are built')
     parser.add_argument('configs', nargs='*')
 
-    args = parser.parse_args()
+    return parser, parser.parse_args()
+
 
+def main():
+    """Main program"""
+    parser, args = parse_args()
     if args.test:
         sys.argv = [sys.argv[0]]
         fail, _ = doctest.testmod()