From 29d1c5bced09fb813efe39783cde01231cf0e8ff Mon Sep 17 00:00:00 2001 From: Jakob Scheid Date: Thu, 10 Sep 2026 13:34:59 +0200 Subject: [PATCH] refactor(cli): move parser creation to a function --- src/jcloud_docsgen/cli/cli.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/jcloud_docsgen/cli/cli.py b/src/jcloud_docsgen/cli/cli.py index a9a6db2..3c25d3e 100644 --- a/src/jcloud_docsgen/cli/cli.py +++ b/src/jcloud_docsgen/cli/cli.py @@ -50,7 +50,15 @@ def error(message: str, exit_code: int = 1): print(f'{_PROGRAM_NAME}: error: {message}', file = sys.stderr) return exit_code -def main(argv = None) -> int: +def create_argument_parser() -> argparse.ArgumentParser: + ''' + Prepares a parser to parse the command-line arguments using + argparse. + + :return: The parser. + :rtype: argparse.ArgumentParser + ''' + common_parser = argparse.ArgumentParser(add_help = False) common_parser.add_argument( 'project_directory', @@ -103,6 +111,10 @@ def main(argv = None) -> int: help = 'indicates whether Markdown tables are allowed in the documentation. By default, Markdown tables are disabled. Warning: Markdown tables are not CommonMark.' ) + return argument_parser + +def main(argv = None) -> int: + argument_parser = create_argument_parser() args = argument_parser.parse_args(argv) if args.output_dir is None: