MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / run

Method run

atomic-cli/src/commands/query/validate.rs:30–99  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

28
29impl Command for Validate {
30 fn run(&self) -> CliResult<()> {
31 // Validation deliberately runs in the CLI process so neither the
32 // daemon nor shared libraries acquire the SHACL engine's MSRV.
33 let root = find_repository_root()?;
34 let snapshot = crate::commands::rpc::workflow_snapshot(&root)?;
35 let dot_dir = Repository::canonical_dot_dir(&root).map_err(CliError::Repository)?;
36 let error = |error: atomic_shacl::ValidationError| CliError::ShaclError(error.to_string());
37 let data =
38 atomic_shacl::snapshot_ntriples(&snapshot.nodes, &snapshot.edges).map_err(error)?;
39 let request = atomic_shacl::ValidationRequest {
40 profile: match self.profile {
41 Profile::Projection => atomic_shacl::Profile::Projection,
42 Profile::Publication => atomic_shacl::Profile::Publication,
43 },
44 shape: self.shape.clone(),
45 node: self.node.clone(),
46 custom: atomic_shacl::load_custom_shapes(&dot_dir.join("shapes")).map_err(error)?,
47 };
48 let report =
49 atomic_shacl::validate_ntriples(&data, &snapshot.identity, &request).map_err(error)?;
50 match self.format {
51 Format::Json => println!(
52 "{}",
53 serde_json::to_string_pretty(&report)
54 .map_err(|error| CliError::Internal(error.into()))?
55 ),
56 Format::Text => {
57 println!(
58 "SHACL {:?}: {}",
59 report.profile,
60 if report.conforms {
61 "conforms"
62 } else {
63 "violations"
64 }
65 );
66 println!(
67 "Snapshot: {}\nProfile: {}",
68 report.snapshot_identity, report.profile_identity
69 );
70 for coverage in &report.target_coverage {
71 println!(
72 " {}: {} evaluated / {} applicable",
73 coverage.shape, coverage.evaluated, coverage.applicable
74 );
75 }
76 for result in &report.results {
77 println!(
78 " {} {}: {} (path {}, shape {}, component {})",
79 result["result_severity"],
80 result["focus_node"],
81 result["result_messages"],
82 result["result_path"],
83 result["source_shape"],
84 result["source_constraint_component"]
85 );
86 }
87 for diagnostic in &report.diagnostics {

Callers

nothing calls this directly

Calls 7

find_repository_rootFunction · 0.85
workflow_snapshotFunction · 0.85
snapshot_ntriplesFunction · 0.85
load_custom_shapesFunction · 0.85
validate_ntriplesFunction · 0.85
cloneMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected