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

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

Supports listing notes, showing a note for a specific ref, adding notes,
appending to existing notes, removing notes, and pruning notes for
unreachable objects.

Edit mode (`git notes edit`) is intentionally not supported because it
launches an interactive editor which cannot be driven programmatically.

# `t`

```elixir
@type t() :: %Git.Commands.Notes{
  add: boolean(),
  append: boolean(),
  force: boolean(),
  list: boolean(),
  message: String.t() | nil,
  notes_ref: String.t() | nil,
  prune: boolean(),
  ref: String.t() | nil,
  remove: String.t() | nil,
  show: String.t() | nil
}
```

# `args`

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

Returns the argument list for `git notes`.

## Examples

    iex> Git.Commands.Notes.args(%Git.Commands.Notes{})
    ["notes", "list"]

    iex> Git.Commands.Notes.args(%Git.Commands.Notes{show: "HEAD"})
    ["notes", "show", "HEAD"]

    iex> Git.Commands.Notes.args(%Git.Commands.Notes{add: true, message: "my note", ref: "HEAD"})
    ["notes", "add", "-m", "my note", "HEAD"]

    iex> Git.Commands.Notes.args(%Git.Commands.Notes{add: true, message: "note", ref: "HEAD", force: true})
    ["notes", "add", "-f", "-m", "note", "HEAD"]

    iex> Git.Commands.Notes.args(%Git.Commands.Notes{append: true, message: "more", ref: "HEAD"})
    ["notes", "append", "-m", "more", "HEAD"]

    iex> Git.Commands.Notes.args(%Git.Commands.Notes{remove: "HEAD"})
    ["notes", "remove", "HEAD"]

    iex> Git.Commands.Notes.args(%Git.Commands.Notes{prune: true})
    ["notes", "prune"]

    iex> Git.Commands.Notes.args(%Git.Commands.Notes{notes_ref: "custom"})
    ["notes", "--ref=custom", "list"]

# `parse_output`

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

Parses the output of `git notes`.

- For `:list` mode, parses lines of "note_sha commit_sha" into a list of maps.
- For `:show` mode, returns the note content as a string.
- For mutation modes (add, append, remove, prune), returns `{:ok, :done}`.

---

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