tmuxopt

package
v0.14.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2023 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package tmuxopt provides an API for loading and parsing tmux options into Go variables.

It provides an API similar to the flag package, but for tmux options.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unquote added in v0.14.1

func Unquote(v []byte) (value string)

Unquote unquotes a string returned by tmux show-option.

Types

type Loader

type Loader struct {
	Tmux tmux.Driver
	// contains filtered or unexported fields
}

Loader loads tmux options into user-specified variables.

func (*Loader) BoolVar added in v0.14.0

func (l *Loader) BoolVar(dest *bool, option string)

BoolVar specifies that the given option should be loaded as a boolean.

func (*Loader) Load

func (l *Loader) Load(req tmux.ShowOptionsRequest) (err error)

Load loads tmux options using the underlying tmux.Driver with the provided request. This will fill all previously specified values and vars.

func (*Loader) MapVar added in v0.3.0

func (l *Loader) MapVar(val MapValue, prefix string)

MapVar specifies that options with the given prefix should be loaded into the provided MapValue.

To support maps, tmuxopt loader works by matching the provided prefix against options produced by tmux. If an option name matches the given prefix, the rest of that name is used as the map key and the value for that option as the value for that key.

For example, if the prefix is, "foo-item-", then given the following options,

foo-item-a x
foo-item-b y
foo-item-c z

We'll get the map,

{a: x, b: y, c: z}

func (*Loader) StringVar

func (l *Loader) StringVar(dest *string, option string)

StringVar specifies that the given option should be loaded as a string.

func (*Loader) Var

func (l *Loader) Var(val Value, option string)

Var specifies that the given option should be loaded into the provided Value object.

type MapValue added in v0.3.0

type MapValue interface {
	Put(key, value string) error
}

MapValue is a receiver for a tmux map value.

type Value

type Value interface {
	Set(value string) error
}

Value is a receiver for a tmux option value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL