[PATCH 07/24] qconfig: Move arg parsing into a separate function
Simon Glass
sjg at chromium.org
Wed Jul 17 17:56:55 CEST 2024
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 at chromium.org>
---
tools/qconfig.py | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/tools/qconfig.py b/tools/qconfig.py
index 07d78387465..d8f0a716fe9 100755
--- a/tools/qconfig.py
+++ b/tools/qconfig.py
@@ -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()
--
2.34.1
More information about the U-Boot
mailing list