# `Git.Commands.Restore`
[🔗](https://github.com/joshrotenberg/git_wrapper_ex/blob/main/lib/git/commands/restore.ex#L1)

Implements the `Git.Command` behaviour for `git restore`.

`git restore` is the modern (Git 2.23+) command for restoring working tree
files, replacing the file-restoration role of `git checkout`. It provides
explicit control over restoring from the index (staged) vs a source commit.

# `t`

```elixir
@type t() :: %Git.Commands.Restore{
  files: [String.t()],
  ours: boolean(),
  patch: boolean(),
  source: String.t() | nil,
  staged: boolean(),
  theirs: boolean(),
  worktree: boolean()
}
```

# `args`

```elixir
@spec args(t()) :: [String.t()]
```

Returns the argument list for `git restore`.

## Examples

    iex> Git.Commands.Restore.args(%Git.Commands.Restore{files: ["README.md"]})
    ["restore", "README.md"]

    iex> Git.Commands.Restore.args(%Git.Commands.Restore{files: ["lib/foo.ex"], staged: true})
    ["restore", "--staged", "lib/foo.ex"]

    iex> Git.Commands.Restore.args(%Git.Commands.Restore{files: ["lib/foo.ex"], source: "HEAD~1"})
    ["restore", "--source", "HEAD~1", "lib/foo.ex"]

# `parse_output`

```elixir
@spec parse_output(String.t(), non_neg_integer()) ::
  {:ok, :done} | {:error, {String.t(), non_neg_integer()}}
```

Parses the output of `git restore`.

`git restore` produces no stdout on success (exit 0), so we return `{:ok, :done}`.

---

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