Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[issue-388] Update CLI tools for the new parsers/writers #401

Merged
merged 7 commits into from
Jan 4, 2023

Conversation

armintaenzertng
Copy link
Collaborator

fixes #388

parsing output uses the tag-value writer to output to stdout

Signed-off-by: Armin Tänzer <armin.taenzer@tngtech.com>
Signed-off-by: Armin Tänzer <armin.taenzer@tngtech.com>
Signed-off-by: Armin Tänzer <armin.taenzer@tngtech.com>
Signed-off-by: Armin Tänzer <armin.taenzer@tngtech.com>
Signed-off-by: Armin Tänzer <armin.taenzer@tngtech.com>
src/formats.py Outdated
YAML = auto()
XML = auto()
TAG_VALUE = auto()
RDF = auto()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RDF or RDF_XML?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use these interchangeably, but RDF_XML is more precise, I guess. Fixed.

if validate:
validation_messages: List[ValidationMessage] = validate_full_spdx_document(document, version)
if validation_messages:
print("The document is invalid. The following issues have been found:")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not valid, the cli should exit with 1

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parser and converter have been merged into a single tool.

print("Please note that this project is currently undergoing a major refactoring and therefore missing "
"a few features which will be added in time.\n"
"In the meanwhile, please use the current PyPI release version 0.7.0.")
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case of error, it should also exit with 1

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parser and converter have been merged into a single tool.

document: Document = parse_file(file)
except NotImplementedError as err:
print(err.args[0])
print("Please note that this project is currently undergoing a major refactoring and therefore missing "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe link to the issues?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

write_file(document, outfile)
except NotImplementedError as err:
print(err.args[0])
print("Please note that this project is currently undergoing a major refactoring and therefore missing "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here: on error exit with code 1

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

def main(file, force):
@click.option("--version", prompt="SPDX version", help="The SPDX version to be used during validation")
@click.option("--validate", is_flag=True, help="validate the provided document")
@click.option("--printout", is_flag=True, help="print the parsed document to stdout in tag-value format")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a pure debug option?

An often seen convention, to print to stdout, is to use the argument -. So -o - implies output is stdout.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@click.option("--version", prompt="SPDX version", help="The SPDX version to be used during validation")
@click.option("--validate", is_flag=True, help="validate the provided document")
@click.option("--printout", is_flag=True, help="print the parsed document to stdout in tag-value format")
def main(file, version, validate, printout):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is there a parser and a converter? I think they both could be the same tool.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parser and converter have been merged into a single tool.

Signed-off-by: Armin Tänzer <armin.taenzer@tngtech.com>
…the README

Signed-off-by: Armin Tänzer <armin.taenzer@tngtech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants