zazuko / rdf-validate-shacl

Validate RDF data purely in JavaScript. An implementation of the W3C SHACL specification on top of the RDFJS stack.
MIT License
95 stars 12 forks source link

Provide a CLI #90

Open tpluscode opened 2 years ago

tpluscode commented 2 years ago

Would it be nice to have a simple CLI provided by this package. I would propose a simple interface which would load data+shapes to memory and offer at least two output "modes"

Standard mode

Writes the validation report to standard output, optionally using type specified in --format

npx rdf-validate-shacl \
  --shapes Person.shape.ttl \
  --data people.nq \
  --format application/ld+json

Without --format it would send n-quads so that the report can be piped easily to other tools

npx rdf-validate-shacl | other-cli-tool

Quiet mode

This would print nothing just return an exit code != 0 when validation failed

npx rdf-validate-shacl \
  --shapes Person.shape.ttl \
  --data people.nq \
  --quiet

Globs for loading the graphs

npx rdf-validate-shacl --shapes shapes/*.ttl --data input/*
tpluscode commented 2 years ago

Given additional dependencies might go for a separate package? rdf-validate-shacl-cli is a big long but logical?

martinmaillard commented 2 years ago

An option is to revive and improve https://github.com/zazuko/rdf-validate-cli to incorporate SHACL

tpluscode commented 2 years ago

Thank you for that. I like this idea

tpluscode commented 2 years ago

Another idea: add --data-graph and --shapes-graph options. This would allow loading a trig/n-quads file and selecting graph(s) for validating portion of the data

All those options should be allowed multiple times. For example

npx rdf-validate-shacl \
  --shapes Person.shapes.ttl \
  --shapes Company.shapes.ttl \
  --data people.nq \
  --data-graph https://example.com/person/Sheldon
  --data-graph https://example.com/person/Amy
  --quiet