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

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

Supports creating, verifying, listing heads of, and unbundling git bundles.
Uses the process dictionary to communicate the operation mode from `args/1`
to `parse_output/2`.

# `t`

```elixir
@type t() :: %Git.Commands.Bundle{
  all: boolean(),
  create: String.t() | nil,
  list_heads: String.t() | nil,
  progress: boolean(),
  quiet: boolean(),
  rev: String.t() | nil,
  unbundle: String.t() | nil,
  verify: String.t() | nil
}
```

# `args`

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

Returns the argument list for `git bundle`.

## Examples

    iex> Git.Commands.Bundle.args(%Git.Commands.Bundle{create: "/tmp/test.bundle", rev: "HEAD"})
    ["bundle", "create", "/tmp/test.bundle", "HEAD"]

    iex> Git.Commands.Bundle.args(%Git.Commands.Bundle{create: "/tmp/test.bundle", all: true})
    ["bundle", "create", "/tmp/test.bundle", "--all"]

    iex> Git.Commands.Bundle.args(%Git.Commands.Bundle{verify: "/tmp/test.bundle"})
    ["bundle", "verify", "/tmp/test.bundle"]

    iex> Git.Commands.Bundle.args(%Git.Commands.Bundle{list_heads: "/tmp/test.bundle"})
    ["bundle", "list-heads", "/tmp/test.bundle"]

    iex> Git.Commands.Bundle.args(%Git.Commands.Bundle{unbundle: "/tmp/test.bundle"})
    ["bundle", "unbundle", "/tmp/test.bundle"]

    iex> Git.Commands.Bundle.args(%Git.Commands.Bundle{create: "/tmp/test.bundle", rev: "HEAD", quiet: true})
    ["bundle", "create", "-q", "/tmp/test.bundle", "HEAD"]

# `parse_output`

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

Parses the output of `git bundle`.

- create (exit 0): `{:ok, :done}`
- verify (exit 0): `{:ok, %{valid: true, raw: stdout}}`
- verify (exit 1): `{:ok, %{valid: false, raw: stdout}}`
- list-heads (exit 0): `{:ok, [%{sha: String.t(), ref: String.t()}]}`
- unbundle (exit 0): `{:ok, :done}`

---

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