Implements the Git.Command behaviour for git var.
Two modes are supported:
- list mode (
git var -l) parses theNAME=valuelines 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.
Summary
Types
@type t() :: %Git.Commands.Var{name: String.t() | nil}
Functions
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"]
@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}}.