Skip to content

Commit

Permalink
[issue-442, review] except SPDXParsingError and delete CLI prompt
Browse files Browse the repository at this point in the history
Signed-off-by: Armin Tänzer <armin.taenzer@tngtech.com>
  • Loading branch information
armintaenzertng committed Jan 26, 2023
1 parent 34fabfd commit d53df99
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/spdx/clitools/pyspdxtools.py
Expand Up @@ -16,6 +16,7 @@
import click

from spdx.model.document import Document
from spdx.parser.error import SPDXParsingError
from spdx.parser.parse_anything import parse_file
from spdx.validation.document_validator import validate_full_spdx_document
from spdx.validation.validation_message import ValidationMessage
Expand All @@ -24,7 +25,7 @@


@click.command()
@click.option("--infile", "-i", prompt="input file path", help="The file containing the document to be validated or converted.")
@click.option("--infile", "-i", help="The file containing the document to be validated or converted.")
@click.option("--outfile", "-o", help="The file to write the converted document to (write a dash for output to stdout or omit for no conversion).")
@click.option("--version", help='The SPDX version to be used during parsing and validation (format "SPDX-2.3"). Will be read from the document if not provided.', default=None)
@click.option("--novalidation", is_flag=True, help="Don't validate the provided document.")
Expand Down Expand Up @@ -64,6 +65,12 @@ def main(infile: str, outfile: str, version: str, novalidation: bool):
"In the meantime, please use the PyPI release version 0.7.0.", file=sys.stderr)
sys.exit(1)

except SPDXParsingError as err:
print("There have been issues while parsing the provided document:", file=sys.stderr)
for message in err.get_messages():
print(message, file=sys.stderr)
sys.exit(1)


if __name__ == "__main__":
main()

0 comments on commit d53df99

Please sign in to comment.