Packages

Production-grade Elixir library for the Open Knowledge Format (OKF). Standards-compliant parsing, validation, lossless I/O, graph indexing, querying, and provenance-aware AI context assembly.

Current section

Files

Jump to
ex_okf lib mix tasks ex_okf.validate.ex
Raw

lib/mix/tasks/ex_okf.validate.ex

defmodule Mix.Tasks.ExOkf.Validate do
@shortdoc "Validate an OKF bundle"
@moduledoc """
Validates an OKF bundle and prints diagnostics.
mix ex_okf.validate path/to/bundle
Exits with status 1 when error-severity diagnostics are present.
Warnings alone do not fail the run.
"""
use Mix.Task
@impl Mix.Task
def run(args) do
{opts, paths, _} = OptionParser.parse(args, strict: [quiet: :boolean])
path = List.first(paths) || Mix.raise("Usage: mix ex_okf.validate PATH")
{:ok, bundle} = ExOKF.load(path)
{status, diags} = ExOKF.validate(bundle)
counts = ExOKF.Diagnostics.counts(diags)
unless opts[:quiet] do
Mix.shell().info("Bundle: #{path}")
Mix.shell().info("Concepts: #{ExOKF.Bundle.size(bundle)}")
Mix.shell().info(
"Diagnostics: #{counts.error} errors, #{counts.warning} warnings, #{counts.info} info"
)
formatted = ExOKF.Diagnostics.format(diags)
if formatted != "", do: Mix.shell().info("\n" <> formatted)
end
if status == :error, do: System.halt(1), else: :ok
end
end