Core LibraryalphaAPI Reference

Choose documentation 1

latest

Current version

latest
English

Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

function libtmux-elixir latest

Selection.one_or_nil/2

Returns one match or nil; a second match remains an error.

Source and package
Qualified name
LibTmux.Selection.one_or_nil/2
Module
LibTmux
Declared in
Selection
Package
libtmux
Source
lib/libtmux/selection.ex
one_or_nil(selection, criteria \\ []) @spec one_or_nil(t(item), LibTmux.Filter.input()) :: {:ok, item | nil} | {:error, LibTmux.Error.t()} when item: LibTmux.Schema.observation()

Examples#

iex> alias LibTmux.{Selection, Snapshot}
iex> {:ok, snapshot} = Snapshot.new(%{pane: [%{id: "%0"}, %{id: "%1"}]},
...> server_instance: "example", captured_from: 0, captured_until: 0,
...> fields: %{pane: [:id]})
iex> panes = Snapshot.panes(snapshot)
iex> Selection.one_or_nil(panes, id: "%9")
{:ok, nil}
iex> {:ok, pane} = Selection.one_or_nil(panes, id: "%0")
iex> pane.id
"%0"
iex> {:error, error} = Selection.one_or_nil(panes)
iex> error.kind
:multiple_matches
Type parameters
Parameters
Esc

Type to search.

Reference preview Open reference