defmodule Mix.Tasks.Dexcord.Coverage do @shortdoc "Verifies declared REST routes cover the pinned Discord OpenAPI spec" @moduledoc "See Dexcord.Api.Coverage. Exits non-zero when in-scope endpoints are missing." use Mix.Task @impl Mix.Task def run(_argv) do Mix.Task.run("compile") case Dexcord.Api.Coverage.check() do {:ok, stats} -> Mix.shell().info( "coverage OK — #{stats.declared} declared, #{stats.spec} in spec, #{stats.allowlisted} allowlisted" ) {:missing, missing} -> Mix.shell().error("MISSING #{length(missing)} in-scope endpoint(s):") Enum.each(missing, &Mix.shell().error(" " <> &1)) exit({:shutdown, 1}) end end end