config

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config reads prs's config file, which names the registry of repos or the owners read in its place, how often the board reads them, how large a diff a pull request's document shows whole, the keys a person adds to it, and the fixes and worktree root the menu of a pull request that cannot merge uses.

Index

Constants

View Source
const (
	FromVariable = RegistryVariable
	FromFile     = "repos_registry in the config file"
	FromOwners   = "owners in the config file"
	FromDefault  = "the default"
	FromViewer   = "no registry at the default, so your own repos on GitHub"
)

Which layer chose the repos prs reads, in the order they are asked.

View Source
const (
	Conflicts     = "conflicts"
	Behind        = "behind"
	FailingChecks = "failing-checks"
	Draft         = "draft"
)

The kinds of blocker a merge fix names, as the fix's command receives them in {blocker}.

View Source
const DefaultClosedRefreshEvery = 5 * time.Minute

DefaultClosedRefreshEvery is how often the board reads the recently closed pull requests, and the Summary tab its history, where the file does not say. Each read costs GitHub about as much as the open one, and what it finds changes only when a pull request closes, which the open read already shows.

View Source
const DefaultDiffSectionMaxLines = 300

DefaultDiffSectionMaxLines is DiffSectionMaxLines where the file does not say: about three screens of the side panel, past which nvim's diff, with its file tree, reads faster than scrolling.

View Source
const DefaultRefreshEvery = time.Minute

DefaultRefreshEvery is how often the board reads each provider while it is open, where the file does not say. Each GitHub read spends points from the token's hourly GraphQL allowance.

View Source
const RegistryVariable = "PRS_REPOS_REGISTRY"

RegistryVariable names the registry for one shell, ahead of the config file.

Variables

BlockerKinds is every kind of blocker a merge fix can name.

Functions

func ClosedPullRequestsDir added in v0.15.0

func ClosedPullRequestsDir() (string, error)

ClosedPullRequestsDir is where the Summary tab and prs summary keep the merged and closed pull requests they count, a SQLite file for each set of repos: closed-pull-requests under $XDG_CACHE_HOME/prs, or ~/.cache/prs where that is unset.

func DefaultRegistry

func DefaultRegistry() (string, error)

DefaultRegistry is where prs looks for the registry when nothing names one: repos.json under $XDG_DATA_HOME, or ~/.local/share where that is unset.

func Fill

func Fill(template string, fields Fields) string

Fill puts a pull request's fields into a Window, which tmux takes as a name.

func FillCommand added in v0.17.0

func FillCommand(template string, fields Fields) string

FillCommand puts a pull request's fields into a Command, with each of ShellQuotedPlaceholders quoted for the shell. A branch name may hold ; or $, and anyone who can open a pull request names one.

func FillRecap added in v0.16.0

func FillRecap(argv []string, fields RecapFields) []string

FillRecap is a Show or Write argv with a window's fields in each placeholder.

func FixPlaceholders added in v0.17.0

func FixPlaceholders() []string

FixPlaceholders are the names a merge fix's Command takes, sorted.

func ListingCacheDir added in v0.6.0

func ListingCacheDir() (string, error)

ListingCacheDir is where the board keeps each provider's last listing, a file for each set of repos it reads, so the next start draws it before any read returns: listings under $XDG_CACHE_HOME/prs, or ~/.cache/prs where that is unset.

func MissingPrograms

func MissingPrograms(programs []string) []string

MissingPrograms is those of programs that are not on PATH.

func Path

func Path() (string, error)

Path is the config file's path under $XDG_CONFIG_HOME, or ~/.config where that is unset.

func Placeholders

func Placeholders() []string

Placeholders are the names a window action's Window and Command, and a merge fix's Window, take, sorted.

func RecapPlaceholders added in v0.16.0

func RecapPlaceholders() []string

RecapPlaceholders are the names FillRecap fills, sorted.

func RecapWritesDir added in v0.16.0

func RecapWritesDir() (string, error)

RecapWritesDir is where the recaps tab keeps each write's output, one file a window, which that window's next write replaces: recap-writes under $XDG_CACHE_HOME/prs, or ~/.cache/prs where that is unset.

func ShellQuotedPlaceholders added in v0.17.0

func ShellQuotedPlaceholders() []string

ShellQuotedPlaceholders are the names among FixPlaceholders that FillCommand quotes, sorted.

func ShellWord added in v0.20.0

func ShellWord(value string) string

ShellWord is value as one shell word, left bare where nothing in it is special, as Python's shlex.quote does.

func TUIDisplayFile added in v0.19.0

func TUIDisplayFile() (string, error)

TUIDisplayFile is where prs tui keeps the tab last moved to and each tab's display settings: tui-display.json under $XDG_STATE_HOME/prs, or ~/.local/state/prs where that is unset.

Types

type Config

type Config struct {
	// File is the path read, whether or not anything was there.
	File string
	// Exists says the file was there to read.
	Exists bool
	// Registry is the repo registry's path. Where it is empty, prs reads Owners whole, and
	// with no Owners either, the repos the GitHub token's own account holds. ReposFrom is
	// the layer that chose.
	Registry  string
	Owners    []string
	ReposFrom string
	// RefreshEvery is how often the board reads each provider again while it is open, and
	// RefreshFrom names the layer that set it.
	RefreshEvery time.Duration
	RefreshFrom  string
	// ClosedRefreshEvery is how often the board reads the recently closed pull requests
	// again, and the Summary tab what changed in the history it counts from.
	// ClosedRefreshFrom names the layer that set it.
	ClosedRefreshEvery time.Duration
	ClosedRefreshFrom  string
	// DiffSectionMaxLines is the most lines a pull request may change for its document's Diff
	// section to show its diff whole. A larger one's section names its size instead.
	// DiffSectionFrom names the layer that set it.
	DiffSectionMaxLines int
	DiffSectionFrom     string
	// WindowActions are the keys the file adds, each opening a tmux window on a pull request.
	WindowActions []WindowAction
	// Recaps are the commands the Recaps tab runs, and empty where the file names none.
	Recaps Recaps
	// WorktreeRoot is where the fix menu adds a worktree to resolve a conflict in, a directory
	// for each repo's checkout under it, and WorktreeRootFrom names the layer that set it.
	WorktreeRoot     string
	WorktreeRootFrom string
	// MergeFixes are the fixes the file adds to the menu a pull request that cannot merge
	// opens, each running its command in a tmux window behind the board.
	MergeFixes []MergeFix
}

Config is what the environment and the file say, with each path expanded.

func Load

func Load() (Config, error)

Load reads the config file and resolves the registry. A file that is not there is no error, and says nothing.

type Fields

type Fields struct {
	Number int
	Repo   string
	Slug   string
	// Path is the repo's checkout, and Worktree the one the menu merges the base into the head
	// in, where a merge there stopped or waits to be pushed.
	Path, Worktree string
	// Head and Base are the branch the pull request merges from and the one it merges into.
	Head, Base string
	// Blocker is the kind from BlockerKinds, and Log the file holding its failing checks' log.
	Blocker, Log string
}

Fields are what a Window or Command can name of a pull request. A window action's take the row's alone, and a merge fix's Command the rest as well, each empty where it does not apply.

type MergeFix added in v0.17.0

type MergeFix struct {
	Key    string `yaml:"key"`
	Label  string `yaml:"label"`
	Detail string `yaml:"detail"`
	// Needs are the programs the command runs, as a window action's are.
	Needs []string `yaml:"needs"`
	// Blockers are the kinds of blocker the fix is offered for, from BlockerKinds.
	Blockers []string `yaml:"blockers"`
	// Window is the tmux window's name, which takes the row's placeholders alone, so the board
	// can find it open from the row. Command takes FixPlaceholders.
	Window  string `yaml:"window"`
	Command string `yaml:"command"`
	// RowReads is what the pull request's row reads while the fix's window is open, and
	// "fixing" where the file does not say.
	RowReads string `yaml:"row_reads"`
}

MergeFix is a fix the menu of a pull request that cannot merge offers, on its key, for the blockers it names. Its command runs in a new tmux window behind the board, started in the pull request's checkout, and it is offered only where every program it needs is on PATH.

func (MergeFix) Missing added in v0.17.0

func (f MergeFix) Missing() []string

Missing is the programs the fix needs that are not on PATH. The menu offers it only where none is.

func (MergeFix) Reads added in v0.17.0

func (f MergeFix) Reads() string

Reads is what the row reads while the fix's window is open.

type RecapFields added in v0.16.0

type RecapFields struct {
	Kind  string
	Label string
}

RecapFields are what a recaps Show or Write can name of a window.

type Recaps added in v0.16.0

type Recaps struct {
	// Needs are the programs the commands run, which an argv starting sh hides. A machine
	// missing one shows no Recaps tab.
	Needs []string `yaml:"needs"`
	List  []string `yaml:"list"`
	Show  []string `yaml:"show"`
	Write []string `yaml:"write"`
}

Recaps are the commands the Recaps tab runs, each an argv run with no shell. List prints the windows a recap is written for, in the order the tab draws them, one a line as its kind and its label, and is left as written, so a list run through sh may hold braces. Show prints one window's recap as markdown, and Write writes it, which is a model call. Show and Write take the names RecapPlaceholders lists. Write may be left out, and the tab then has no key that writes.

func (Recaps) Missing added in v0.16.0

func (r Recaps) Missing() []string

Missing is the programs the commands need, Needs and each argv's first, that are not on PATH. prs shows the Recaps tab only where none is.

func (Recaps) Named added in v0.16.0

func (r Recaps) Named() bool

Named says the file names the Recaps tab's commands.

type WindowAction

type WindowAction struct {
	Key    string `yaml:"key"`
	Label  string `yaml:"label"`
	Detail string `yaml:"detail"`
	// Needs are the programs the command runs, checked before the window opens, because
	// tmux reports a window opened even when its command cannot start.
	Needs []string `yaml:"needs"`
	// Providers limits the key to pull requests these providers host. Empty means any.
	Providers []string `yaml:"providers"`
	// Window is the tmux window's name, and Command the shell command it runs. Both take
	// the names Placeholders lists.
	Window  string `yaml:"window"`
	Command string `yaml:"command"`
	// RunsReviewRound says the command runs a Claude review round on the pull request, so the
	// row reads the round as running while the window is open and the round has not finished.
	RunsReviewRound bool `yaml:"runs_review_round"`
}

WindowAction is a key that runs a command in a new tmux window, started in the pull request's checkout. It is offered only where every program it needs is on PATH.

func (WindowAction) Missing

func (a WindowAction) Missing() []string

Missing is the programs the action needs that are not on PATH. The board offers its key only where none is.

Jump to

Keyboard shortcuts

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