refactor(cli): move parser creation to a function

This commit is contained in:
jakob.scheid committed 2026-09-10 13:36:06 +02:00
1 parent 3ab9884be0
commit 29d1c5bced
1 file changed
+13 -1
+13 -1
View File
@@ -50,7 +50,15 @@ def error(message: str, exit_code: int = 1):
print(f'{_PROGRAM_NAME}: error: {message}', file = sys.stderr) print(f'{_PROGRAM_NAME}: error: {message}', file = sys.stderr)
return exit_code 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 = argparse.ArgumentParser(add_help = False)
common_parser.add_argument( common_parser.add_argument(
'project_directory', '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.' 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) args = argument_parser.parse_args(argv)
if args.output_dir is None: if args.output_dir is None: