Compare commits

...

3 Commits

4 changed files with 37 additions and 11 deletions

1
.gitignore vendored
View File

@ -14,6 +14,7 @@ vsg/version_info.*
# IDE files
.idea/
.vscode/
venv
# Ignore external repos used for tests
vsg/tests/external_repos/repos

View File

@ -132,7 +132,8 @@ def main():
fStatus, testCase, dJsonEntry, sOutputStd, sOutputErr, bKeepProcessingFiles = f((0, 'stdin'))
lReturn.append((fStatus, testCase, dJsonEntry))
if sOutputStd:
print(sOutputStd)
if not commandLineArguments.stdout:
print(sOutputStd)
if sOutputErr:
print(sOutputErr, file=sys.stderr)
@ -141,7 +142,8 @@ def main():
fStatus, testCase, dJsonEntry, sOutputStd, sOutputErr, bKeepProcessingFiles = f((iIndex + int(commandLineArguments.stdin), sFileName))
lReturn.append((fStatus, testCase, dJsonEntry))
if sOutputStd:
print(sOutputStd)
if not commandLineArguments.stdout:
print(sOutputStd)
if sOutputErr:
print(sOutputErr, file=sys.stderr)
if bKeepProcessingFiles:
@ -154,7 +156,8 @@ def main():
fStatus, testCase, dJsonEntry, sOutputStd, sOutputErr, bKeepProcessingFiles = tResult
lReturn.append((fStatus, testCase, dJsonEntry))
if sOutputStd:
print(sOutputStd)
if not commandLineArguments.stdout:
print(sOutputStd)
if sOutputErr:
print(sOutputErr, file=sys.stderr)
if bKeepProcessingFiles:
@ -181,7 +184,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():

View File

@ -122,10 +122,11 @@ def apply_rules(commandLineArguments, oConfig, tIndexFileName):
if commandLineArguments.fix:
if commandLineArguments.backup:
create_backup_file(sFileName)
oRules.fix(
commandLineArguments.fix_phase, commandLineArguments.skip_phase, fix_only
)
write_vhdl_file(oVhdlFile, oConfig.dConfig)
oRules.fix(commandLineArguments.fix_phase, commandLineArguments.skip_phase, fix_only)
if commandLineArguments.stdout:
print("\n".join(oVhdlFile.get_lines()[1:]))
else:
write_vhdl_file(oVhdlFile, oConfig.dConfig)
oRules.clear_violations()
oRules.check_rules(

View File

@ -72,6 +72,12 @@ def parse_command_line_arguments():
parser.add_argument('--fix_only', action='store', help='Restrict fixing via JSON file.')
parser.add_argument('--stdin', action='store_true', default=False,
help='Read VHDL input from stdin, disables all other file selections, disables multiprocessing')
parser.add_argument(
"--stdout",
action="store_true",
default=False,
help="Write all file changes stdout instead of writing them in a file, enabling this will disable all diagnostics and just print a file fix",
)
parser.add_argument('--force_fix', action='store_true', default=False,
help='ALPHA: Apply fixes if syntax errors are detected.')
@ -84,9 +90,9 @@ def parse_command_line_arguments():
type=__check_strict_positive,
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('filename_args', metavar='FILENAME', type=__is_valid_file, nargs='*', default=[],
help='File to analyze')
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()
@ -94,6 +100,7 @@ def parse_command_line_arguments():
validate_ap_argument(args_)
fix_filename_argument(args_)
fix_configuration_argument(args_)
validate_stdout_argument(args_)
if sys.platform == "win32":
# Work around https://bugs.python.org/issue26903
@ -133,6 +140,17 @@ def validate_backup_argument(args_):
print('ERROR: --backup argument requires --fix argument')
sys.exit(1)
def validate_stdout_argument(args_):
"""
The function validates the stdout option is only present when the fix option is also present.
"""
if args_.stdout and not args_.fix:
print("ERROR: --stdout argument requires --fix argument")
sys.exit(1)
if args_.stdout and not args_.stdin and len(args_.filename)>1:
print("ERROR: --stdout argument cannot be used with multiples files")
sys.exit(1)
def validate_ap_argument(args_):
'''