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

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

Supports listing stash entries (default), saving (pushing) changes to the
stash, popping the top stash entry, and dropping a stash entry.

# `t`

```elixir
@type t() :: %Git.Commands.Stash{
  drop: boolean(),
  include_untracked: boolean(),
  index: non_neg_integer() | nil,
  list: boolean(),
  message: String.t() | nil,
  pop: boolean(),
  save: boolean()
}
```

# `args`

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

Returns the argument list for `git stash`.

- If `:save` is true, builds `git stash push [-m <message>] [-u]`.
- If `:pop` is true, builds `git stash pop [stash@{index}]`.
- If `:drop` is true, builds `git stash drop [stash@{index}]`.
- Otherwise, lists stash entries with `git stash list`.

## Examples

    iex> Git.Commands.Stash.args(%Git.Commands.Stash{})
    ["stash", "list"]

    iex> Git.Commands.Stash.args(%Git.Commands.Stash{save: true})
    ["stash", "push"]

    iex> Git.Commands.Stash.args(%Git.Commands.Stash{save: true, message: "wip"})
    ["stash", "push", "-m", "wip"]

    iex> Git.Commands.Stash.args(%Git.Commands.Stash{pop: true})
    ["stash", "pop"]

    iex> Git.Commands.Stash.args(%Git.Commands.Stash{drop: true, index: 1})
    ["stash", "drop", "stash@{1}"]

# `parse_output`

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

Parses the output of `git stash`.

For list operations (exit 0), parses each line into a `Git.StashEntry` struct.
For save/pop/drop operations (exit 0), returns `{:ok, :done}`.
On failure, returns `{:error, {stdout, exit_code}}`.

---

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