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

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

Two modes are supported:

  * list mode (`git var -l`) parses the `NAME=value` lines into a map
  * single-variable mode (`git var <NAME>`) returns the trimmed value string

Set `:name` to look up a single variable; leave it `nil` to list all.

# `t`

```elixir
@type t() :: %Git.Commands.Var{name: String.t() | nil}
```

# `args`

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

Returns the argument list for `git var`.

## Examples

    iex> Git.Commands.Var.args(%Git.Commands.Var{})
    ["var", "-l"]

    iex> Git.Commands.Var.args(%Git.Commands.Var{name: "GIT_EDITOR"})
    ["var", "GIT_EDITOR"]

# `parse_output`

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

Parses the output of `git var`.

In list mode, returns `{:ok, map}` mapping each variable name to its value.
In single-variable mode, returns `{:ok, value}` with the trimmed string. On a
non-zero exit code, returns `{:error, {stdout, exit_code}}`.

---

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