# `Adze.Move`
[🔗](https://github.com/matthewlehner/adze/blob/v0.1.0/lib/adze/move.ex#L1)

`mv` — reorder a logical definition within a single file.

Moves a `def` (with its attached `@spec`/`@doc`/leading comments and
every clause — i.e. the whole `Adze.Definition` group) to just before
another `def` in the same module.

Scope:

  * Single file, single module. Both `--definition` and `--before` must
    resolve to defs in the same `defmodule`. Cross-module moves are
    explicitly out of scope — that's `extract`'s job.
  * `--before` is the only supported anchor (no `--after`).
  * `mv/2` is pure (returns the diff + new source). `mv!/2` writes the
    file.

## Usage

    iex> Adze.Move.mv(source, definition: "bar/2", before: "baz/1")
    {:ok, %{diff: "...", new_source: "..."}}

    Adze.Move.mv!("lib/foo.ex", definition: "bar/2", before: "baz/1")
    # → {:ok, %{diff: ..., new_source: ...}}  +  rewrites lib/foo.ex

# `opts`

```elixir
@type opts() :: [
  definition: Adze.Definition.definition_spec(),
  before: Adze.Definition.definition_spec(),
  include_attrs: [atom()]
]
```

# `result`

```elixir
@type result() :: %{diff: String.t(), new_source: String.t()}
```

# `mv`

```elixir
@spec mv(String.t(), opts()) :: {:ok, result()} | {:error, term()}
```

# `mv!`

```elixir
@spec mv!(Path.t(), opts()) :: {:ok, result()} | {:error, term()}
```

# `mv_file`

```elixir
@spec mv_file(Path.t(), opts()) :: {:ok, result()} | {:error, term()}
```

---

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