generated from jCloud/repository-template
refactor(cli): move parser creation to a function
This commit is contained in:
1 file changed
+13
-1
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user