# `GitHoox.Hook`
[🔗](https://github.com/sgerrand/git_hoox/blob/v0.1.0/lib/git_hoox/hook.ex#L1)

Behaviour for git_hoox hooks.

Implement `run/2` to execute logic. Optionally implement `default_opts/0`
to supply per-hook defaults (e.g. `stage_fixed: true` for formatters).

## Example

    defmodule MyApp.Hooks.Sobelow do
      @behaviour GitHoox.Hook

      @impl true
      def default_opts, do: [files: ~w(lib/**/*.ex)]

      @impl true
      def run([], _opts), do: :ok
      def run(files, _opts) do
        case System.cmd("mix", ["sobelow", "--exit" | files], stderr_to_stdout: true) do
          {_, 0} -> :ok
          {out, code} -> {:error, {code, out}}
        end
      end
    end

# `files`

```elixir
@type files() :: [GitHoox.path()]
```

Files matched by hook's `:files` glob, after staging filter.

# `opts`

```elixir
@type opts() :: keyword()
```

Hook options merged from `default_opts/0` and user config.

# `default_opts`
*optional* 

```elixir
@callback default_opts() :: keyword()
```

Per-hook default options. Merged with user config; user wins on conflict.

# `run`

```elixir
@callback run(files(), opts()) :: GitHoox.hook_result()
```

Run hook against `files`.

Return `:ok` for read-only success. Return `{:ok, modified}` listing files
the hook mutated — runner re-stages them if `stage_fixed: true`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
