Commit 7d7aad4b authored by Tristan Gingold's avatar Tristan Gingold

__main__: add a top-level function to support a testsuite.

parent 81895179
......@@ -32,7 +32,7 @@ from .module_pool import ModulePool
from ._version import __version__
def main():
def hdlmake(args):
"""This is the main function, where HDLMake starts.
Here, we make the next processes:
-- parse command
......@@ -48,7 +48,7 @@ def main():
#
# PARSE & GET OPTIONS
#
options = _get_options(sys, parser)
options = _get_options(args, parser)
# Create a ModulePool object, this will become our workspace
modules_pool = ModulePool(options)
......@@ -62,7 +62,6 @@ def _action_runner(modules_pool):
options = modules_pool.options
if options.command == "manifest-help":
ManifestParser().print_help()
quit(0)
elif options.command == "makefile":
modules_pool.makefile()
elif options.command == "fetch":
......@@ -190,18 +189,22 @@ def _get_parser():
return parser
def _get_options(sys_aux, parser):
def _get_options(args, parser):
"""Function that decodes and set the provided command user options"""
options = None
if len(sys_aux.argv[1:]) == 0:
if len(args) == 0:
options = parser.parse_args(['makefile'])
elif len(sys_aux.argv[1:]) == 2 and (
sys_aux.argv[1] == '-f' or sys_aux.argv[1] == '--filename'):
options = parser.parse_args(['makefile'] + sys_aux.argv[1:])
elif len(args) == 2 and (
args[0] == '-f' or args[0] == '--filename'):
options = parser.parse_args(['makefile'] + args)
else:
options = parser.parse_args(sys_aux.argv[1:])
options = parser.parse_args(args)
return options
def main():
"""Entry point used by the executable"""
hdlmake(sys.argv[1:])
if __name__ == "__main__":
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment