# `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 a shallow (`--depth`) or partial (`--filter`) clone, `--sparse`,
`--single-branch`, `--no-checkout`, `--bare`, `--mirror`,
`--recurse-submodules`, a named origin (`--origin`), repo config to set in the
new clone (`--config`), a specific `--branch`, and an optional target
directory.

# `t`

```elixir
@type t() :: %Git.Commands.Clone{
  bare: boolean(),
  branch: String.t() | nil,
  depth: pos_integer() | nil,
  directory: String.t() | nil,
  filter: String.t() | nil,
  mirror: boolean(),
  no_checkout: boolean(),
  origin: String.t() | nil,
  recurse_submodules: boolean(),
  set_config: [{String.t(), String.t()}],
  single_branch: boolean(),
  sparse: boolean(),
  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 before the
URL, and a target directory (when set) is appended after it.

## 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", filter: "blob:none"})
    ["clone", "--filter=blob:none", "https://example.com/repo.git"]

    iex> Git.Commands.Clone.args(%Git.Commands.Clone{url: "https://example.com/repo.git", bare: true})
    ["clone", "--bare", "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*
