diff options
author | Jack Rosenthal <jrosenth@chromium.org> | 2022-01-11 12:40:32 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-01-12 19:31:39 +0000 |
commit | 4b83d19fa6b016ae09b55f0f3d6f0e1888c0f8bd (patch) | |
tree | 55296d3565c40bdabf55e029484d5d038c7a2be1 | |
parent | 3e90dbe69db14753db2733e20ebf4f69e97a910a (diff) | |
download | chrome-ec-4b83d19fa6b016ae09b55f0f3d6f0e1888c0f8bd.tar.gz |
zephyr: zmake: Separate out the argument parser from main function
Move the code which generates the argument parser to a separate
function, get_argparser. This is intended that we can access the
argument parser to generate documentation about zmake's options and
subcommands.
BUG=b:180609783
BRANCH=none
TEST=unit tests pass
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Change-Id: I1f14aa4e298d0ec47fb51e7b3bfad52bab990e85
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3382478
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
-rw-r--r-- | zephyr/zmake/zmake/__main__.py | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/zephyr/zmake/zmake/__main__.py b/zephyr/zmake/zmake/__main__.py index 1f9c506ee5..2df03654f0 100644 --- a/zephyr/zmake/zmake/__main__.py +++ b/zephyr/zmake/zmake/__main__.py @@ -93,20 +93,12 @@ log_level_map = { } -def main(argv=None): - """The main function. - - Args: - argv: Optionally, the command-line to parse, not including argv[0]. +def get_argparser(): + """Get the argument parser. Returns: - Zero upon success, or non-zero upon failure. + An argparse.ArgumentParser. """ - if argv is None: - argv = sys.argv[1:] - - maybe_reexec(argv) - parser = argparse.ArgumentParser( prog="zmake", description="Chromium OS's meta-build tool for Zephyr", @@ -273,6 +265,24 @@ def main(argv=None): help="The build directory used during configuration", ) + return parser + + +def main(argv=None): + """The main function. + + Args: + argv: Optionally, the command-line to parse, not including argv[0]. + + Returns: + Zero upon success, or non-zero upon failure. + """ + if argv is None: + argv = sys.argv[1:] + + maybe_reexec(argv) + + parser = get_argparser() opts = parser.parse_args(argv) # Default logging |