From e72d21499659f1bb4b641b9a83698354eb170eef Mon Sep 17 00:00:00 2001 From: umarcor Date: Fri, 18 Jun 2021 20:29:24 +0200 Subject: pyGHDL/cli/DOM: if an exception arises return non zero exit code and do not pretty print --- pyGHDL/cli/DOM.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'pyGHDL/cli/DOM.py') diff --git a/pyGHDL/cli/DOM.py b/pyGHDL/cli/DOM.py index abf1f0af8..6bd6c8a7e 100755 --- a/pyGHDL/cli/DOM.py +++ b/pyGHDL/cli/DOM.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 from sys import argv +from sys import exit as sysexit from pathlib import Path @@ -38,23 +39,25 @@ class Application: print("\n".join(buffer)) -def main(): - items = argv[1:] +def main(items): + _exitcode = 0 + if len(items) < 1: print("Please, provide the files to be analyzed as CLI arguments.") print("Using for demo purposes.\n") items = ["testsuite/pyunit/SimpleEntity.vhdl"] for item in items: - print("ยท", item) try: app = Application() app.addFile(Path(item), "default_lib") + app.prettyPrint() except GHDLBaseException as ex: print(ex) + _exitcode = 1 - app.prettyPrint() + return _exitcode if __name__ == "__main__": - main() + sysexit(main(argv[1:])) -- cgit v1.2.3