Skip to main content

lib/mix/tasks/ttycast.reindex.ex

defmodule Mix.Tasks.Ttycast.Reindex do
  @moduledoc "Rebuild a ttycast trailer index."
  use Mix.Task

  @shortdoc "Rebuild .ttycast index"

  @impl true
  def run([path]) do
    case TTYCast.reindex(path) do
      {:ok, result} -> Mix.shell().info("reindexed #{result.chunks} chunks in #{result.path}")
      {:error, reason} -> Mix.raise("reindex failed: #{inspect(reason)}")
    end
  end

  def run(_argv), do: Mix.raise("usage: mix ttycast.reindex PATH")
end