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

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

Supports cloning a repository with optional `--depth` (shallow clone) and
`--branch` flags. An optional target directory name may also be specified.

# `t`

```elixir
@type t() :: %Git.Commands.Clone{
  branch: String.t() | nil,
  depth: pos_integer() | nil,
  directory: String.t() | nil,
  url: String.t()
}
```

# `args`

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

Returns the argument list for `git clone`.

Always includes the repository URL. Optional flags are appended in order:
`--depth=N`, `--branch=NAME`, and a target directory when set.

## Examples

    iex> Git.Commands.Clone.args(%Git.Commands.Clone{url: "https://example.com/repo.git"})
    ["clone", "https://example.com/repo.git"]

    iex> Git.Commands.Clone.args(%Git.Commands.Clone{url: "https://example.com/repo.git", depth: 1})
    ["clone", "--depth=1", "https://example.com/repo.git"]

    iex> Git.Commands.Clone.args(%Git.Commands.Clone{url: "https://example.com/repo.git", branch: "main", depth: 1})
    ["clone", "--depth=1", "--branch=main", "https://example.com/repo.git"]

    iex> Git.Commands.Clone.args(%Git.Commands.Clone{url: "https://example.com/repo.git", directory: "my-repo"})
    ["clone", "https://example.com/repo.git", "my-repo"]

# `parse_output`

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

Parses the output of `git clone`.

On success (exit code 0), returns `{:ok, :done}`.
On failure, returns `{:error, {stdout, exit_code}}`.

---

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