Current section
Files
Jump to
Current section
Files
lib/mix/tasks/ex_okf.inspect.ex
defmodule Mix.Tasks.ExOkf.Inspect do
@shortdoc "Inspect an OKF bundle"
@moduledoc """
Prints a summary of an OKF bundle.
mix ex_okf.inspect path/to/bundle
"""
use Mix.Task
@impl Mix.Task
def run(args) do
path = List.first(args) || Mix.raise("Usage: mix ex_okf.inspect PATH")
{:ok, bundle} = ExOKF.load(path)
Mix.shell().info("OKF bundle: #{bundle.root}")
Mix.shell().info("okf_version: #{bundle.okf_version || "(undeclared)"}")
Mix.shell().info("concepts: #{ExOKF.Bundle.size(bundle)}")
Mix.shell().info("indexes: #{map_size(bundle.indexes)}")
Mix.shell().info("logs: #{map_size(bundle.logs)}")
Mix.shell().info("types: #{Enum.join(ExOKF.Query.types(bundle), ", ")}")
Mix.shell().info("tags: #{Enum.join(ExOKF.Query.tags(bundle), ", ")}")
Mix.shell().info("\nConcepts:")
for c <- ExOKF.Bundle.concepts(bundle) do
Mix.shell().info(" - #{c.id} [#{c.type}] #{ExOKF.Concept.display_title(c)}")
end
:ok
end
end