From 497f7caaafc3c8669c752d13f66c84f5c562bdec Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Fri, 22 Nov 2024 23:54:55 -0600 Subject: [PATCH] Fixes stderr being muted and add a --no-failure --- .gitignore | 1 + vsg/__main__.py | 14 +++++++------- vsg/cmd_line_args.py | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index f56d47f2..fe2794eb 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ release_notes.txt # IDE files .idea/ .vscode/ +venv # Ignore external repos used for tests tests/external_repos/repos diff --git a/vsg/__main__.py b/vsg/__main__.py index 49b292a0..ff04cf98 100644 --- a/vsg/__main__.py +++ b/vsg/__main__.py @@ -136,8 +136,7 @@ def main(): if not commandLineArguments.stdout: print(sOutputStd) if sOutputErr: - if not commandLineArguments.stdout: - print(sOutputErr, file=sys.stderr) + print(sOutputErr, file=sys.stderr) else: for iIndex, sFileName in enumerate(commandLineArguments.filename): @@ -147,8 +146,7 @@ def main(): if not commandLineArguments.stdout: print(sOutputStd) if sOutputErr: - if not commandLineArguments.stdout: - print(sOutputErr, file=sys.stderr) + print(sOutputErr, file=sys.stderr) if bKeepProcessingFiles: break @@ -162,8 +160,7 @@ def main(): if not commandLineArguments.stdout: print(sOutputStd) if sOutputErr: - if not commandLineArguments.stdout: - print(sOutputErr, file=sys.stderr) + print(sOutputErr, file=sys.stderr) if bKeepProcessingFiles: break @@ -188,7 +185,10 @@ def main(): if commandLineArguments.quality_report: quality_report.write(commandLineArguments, dJson) - sys.exit(fExitStatus) + if commandLineArguments.no_failure: + sys.exit(0) + else: + sys.exit(fExitStatus) def create_json_dictionary(): diff --git a/vsg/cmd_line_args.py b/vsg/cmd_line_args.py index 19aa3ab4..518bc89d 100644 --- a/vsg/cmd_line_args.py +++ b/vsg/cmd_line_args.py @@ -85,6 +85,7 @@ def parse_command_line_arguments(): help="number of parallel jobs to use, default is the number of cpu cores", ) parser.add_argument("--debug", default=False, action="store_true", help="Displays verbose debug information") + parser.add_argument("--no-failure", default=False, action="store_true", help="Always exits with exit code 0, usefull for scripting") parser.add_argument("filename_args", metavar="FILENAME", type=__is_valid_file, nargs="*", default=[], help="File to analyze") args_ = parser.parse_args()