herdr

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package herdr is the only code that calls herdr. It runs the herdr CLI with argument lists, parses its JSON replies, and turns error replies into *Error.

Inside a herdr pane the CLI finds its session through HERDR_SOCKET_PATH, which herdr injects, so the panel talks to whichever session it runs in.

Index

Constants

This section is empty.

Variables

View Source
var MinVersion = [3]int{0, 8, 0}

MinVersion is the oldest herdr whose JSON replies this adapter was written against.

Functions

func InPane

func InPane() bool

InPane reports whether the panel itself runs inside a herdr pane.

func IsNotRunning

func IsNotRunning(err error) bool

IsNotRunning reports whether err means no herdr server is listening.

Types

type Client

type Client struct {
	Bin   string
	Trace func(argv []string, err error)
}

Client runs herdr commands. Trace, when set, receives every command line with its error, so callers can put the exact herdr calls in the audit log.

func New

func New() *Client

func (*Client) Check

func (c *Client) Check(ctx context.Context) (string, error)

Check confirms herdr is installed, new enough and has a running server. It returns a one-line status for the top bar.

func (*Client) CreateWorkspace

func (c *Client) CreateWorkspace(ctx context.Context, cwd, label string, focus bool) (Workspace, Pane, error)

CreateWorkspace makes a workspace whose first pane starts in cwd.

func (*Client) FocusWorkspace

func (c *Client) FocusWorkspace(ctx context.Context, id string) error

func (*Client) Pane

func (c *Client) Pane(ctx context.Context, id string) (Pane, error)

Pane returns one pane, or an error such as pane_not_found once it is closed.

func (*Client) Panes

func (c *Client) Panes(ctx context.Context, workspaceID string) ([]Pane, error)

func (*Client) ProcessInfo

func (c *Client) ProcessInfo(ctx context.Context, pane string) (ProcessInfo, error)

func (*Client) Rename

func (c *Client) Rename(ctx context.Context, pane, label string) error

func (*Client) Run

func (c *Client) Run(ctx context.Context, pane, command string) error

Run types command into the pane's shell and presses Enter.

func (*Client) SendKeys

func (c *Client) SendKeys(ctx context.Context, pane string, keys ...string) error

func (*Client) Split

func (c *Client) Split(ctx context.Context, pane, direction, cwd string, focus bool) (Pane, error)

Split opens a new pane next to pane, starting in cwd.

func (*Client) Version

func (c *Client) Version(ctx context.Context) ([3]int, string, error)

Version returns the installed herdr version, e.g. [0 8 2].

func (*Client) WithTrace

func (c *Client) WithTrace(calls *[]string) *Client

WithTrace returns a copy of c that appends each call to *calls.

func (*Client) Workspaces

func (c *Client) Workspaces(ctx context.Context) ([]Workspace, error)

type Error

type Error struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

Error is an error reply from the herdr server, e.g. server_not_running.

func (*Error) Error

func (e *Error) Error() string

type Pane

type Pane struct {
	ID          string `json:"pane_id"`
	WorkspaceID string `json:"workspace_id"`
	TabID       string `json:"tab_id"`
	Cwd         string `json:"cwd"`
	Label       string `json:"label"`
	Focused     bool   `json:"focused"`
}

type Process

type Process struct {
	PID  int      `json:"pid"`
	Name string   `json:"name"`
	Argv []string `json:"argv"`
}

type ProcessInfo

type ProcessInfo struct {
	ShellPID        int       `json:"shell_pid"`
	ForegroundGroup int       `json:"foreground_process_group_id"`
	Foreground      []Process `json:"foreground_processes"`
}

type Workspace

type Workspace struct {
	ID     string `json:"workspace_id"`
	Label  string `json:"label"`
	Number int    `json:"number"`
}

Jump to

Keyboard shortcuts

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