conf

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 10 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 conf reads sitrep's settings: the environment first, then sitrep.conf in the state folder. The file is read, never run, so it holds NAME=value lines only (single quotes, double quotes, backslashes and $'...' are understood, so what printf %q wrote reads back; export, variables and commands are not, and a line that is not NAME=value, such as a # comment, is ignored). The bash status line used to source the file, which let it override the environment and run code; that is gone.

Index

Constants

View Source
const (
	DefaultQueueItems       = 5
	DefaultHighlightSeconds = 60
	DefaultHighlightSGR     = "48;5;238"
)

Defaults of the settings that have one.

View Source
const (
	DefaultLogMaxMB = 10
	DefaultLogDays  = 30
)

Defaults of the history log.

View Source
const DefaultAttnFade = 600

DefaultAttnFade is how many seconds a session that needs the user keeps the needs-you colour.

View Source
const DefaultTUIInterval = 3 * time.Second

DefaultTUIInterval is how often the dashboard refreshes when nothing says otherwise.

View Source
const Examples = `` /* 3523-byte string literal not displayed */

Examples is the text of the block: every setting, commented out, with its default.

View Source
const MaxColors = 300

MaxColors is the longest SITREP_COLORS the dashboard is given.

Variables

View Source
var Editable = []string{"SITREP_THEME", "SITREP_COLORS"}

Editable are the settings Edit may change: the two that the colour tool owns.

View Source
var ErrMultiline = errors.New("the command has more than one line")

ErrMultiline says a command cannot be kept in sitrep.conf, which holds one setting per line.

View Source
var StatusLineNames = []string{"objective", "progress", "now", "queue"}

StatusLineNames are the lines of the status line's block, in the order they are drawn.

Functions

func Edit added in v1.0.0

func Edit(body string, changes []Change) (out string, dropped int, err error)

Edit makes the file text that follows from body and the changes, and says how many later lines of a changed name it dropped. A line is ours when it starts with NAME= at the first column, the test FromFile makes, so a commented, indented or `export`ed line is the user's and stays. The first line of a name is replaced where it stands and the later ones go, since the reader takes the first. A name with no line is added above the examples block, or at the end. A value the dashboard would not accept, or a name that is not Editable, is an error. Everything else is kept byte for byte, and a file of \r\n lines gets \r\n lines.

func Line added in v1.0.0

func Line(body, name string) string

Line is the first line of body that sets name, as it stands, or "".

func OtherLines added in v1.0.0

func OtherLines(body string) string

OtherLines is body without the lines Edit may change, to check that a write changed nothing else.

func Quote

func Quote(s string) string

Quote writes s as one shell word that Unquote reads back: in single quotes, a single quote written as '\”.

func Unquote

func Unquote(s string) string

Unquote reads one shell word the way sitrep.conf holds it, without running anything: single quotes, double quotes and backslash escapes and $'...' are understood, and variables and commands are left as they are.

func ValidColors added in v1.0.0

func ValidColors(v string) bool

ValidColors says whether the dashboard would be given v as the colour overrides: at most MaxColors characters of those a list is made of.

func ValidTheme added in v1.0.0

func ValidTheme(v string) bool

ValidTheme says whether the dashboard would read v as a theme name: lower-case letters and hyphens, at most 20.

Types

type Change added in v1.0.0

type Change struct {
	Name  string
	Value *string
}

Change is the new text of one setting of sitrep.conf, or its removal when Value is nil.

type Conf

type Conf struct {
	File   string              // path of sitrep.conf
	Getenv func(string) string // the environment; os.Getenv when nil
}

Conf looks settings up.

func Open

func Open(stateDir string) Conf

Open names the conf file in a state folder.

func (Conf) AttnFade added in v1.0.0

func (c Conf) AttnFade() int

AttnFade is how long a session that needs the user keeps the needs-you colour (SITREP_ATTN_FADE), in seconds; 0 never fades.

func (Conf) Backup added in v1.0.0

func (c Conf) Backup(body string, now time.Time) (string, error)

Backup saves body, as it was read, as sitrep.conf.bak.<time> beside sitrep.conf (the state folder, not the folder a link leads to, so a dotfiles repository does not collect backups): owner-only, never over an earlier backup.

func (Conf) BackupWarnDays added in v1.0.7

func (c Conf) BackupWarnDays() int

BackupWarnDays is how many days old the last backup may be before the status line and the dashboard say so (SITREP_BACKUP_WARN): 2 when it is not set, 0 for never, and at most 3650.

func (Conf) CheckUpdates added in v0.6.0

func (c Conf) CheckUpdates() bool

CheckUpdates says whether sitrep may look once a day for a newer release (SITREP_CHECK_UPDATES); 0, false and no turn it off.

func (Conf) Colors added in v0.6.0

func (c Conf) Colors() string

Colors is the dashboard's colour overrides (SITREP_COLORS), such as "accent=#ff8800,attn=#400020". Only the characters such a list is made of are accepted, and the dashboard reads the entries itself, ignoring each one it cannot use.

func (Conf) DropExamples added in v0.7.0

func (c Conf) DropExamples() error

DropExamples removes the block. The file goes when nothing else is left.

func (Conf) DropHUD

func (c Conf) DropHUD() error

DropHUD removes our SITREP_HUD_CMD line. Every other line is the user's and stays; the file goes when nothing else is left.

func (Conf) FromFile

func (c Conf) FromFile(name string) string

FromFile is a setting as the file holds it, whatever the environment says: setup and its removal save and restore what is in the file.

func (Conf) Get

func (c Conf) Get(name string) string

Get returns a setting: the environment wins, then the first NAME=value line of the file. It is empty when unset.

func (Conf) HighlightSGR

func (c Conf) HighlightSGR() string

HighlightSGR is the terminal style of the highlight. Only digits and semicolons are accepted, because the value reaches the terminal.

func (Conf) HighlightSeconds

func (c Conf) HighlightSeconds() int

HighlightSeconds is how long a session counts as recently active (SITREP_HIGHLIGHT_SECONDS); 0 turns the highlight off.

func (Conf) LogDays added in v1.0.0

func (c Conf) LogDays() int

LogDays is the age in days after which an entry is dropped (SITREP_LOG_DAYS); 0 or a bad value is the default.

func (Conf) LogMaxMB added in v1.0.0

func (c Conf) LogMaxMB() int

LogMaxMB is the most megabytes the two files of the log hold together (SITREP_LOG_MAX); 0 or a bad value is the default.

func (Conf) LogOn added in v1.0.0

func (c Conf) LogOn() bool

LogOn says whether the history log is on (SITREP_LOG): it is off unless this is 1, on, true or yes.

func (Conf) PutExamples added in v0.7.0

func (c Conf) PutExamples() error

PutExamples makes the examples block the last thing in the file, replacing an earlier copy of it. The user's lines are kept as they are, and nothing is written when the file already ends with the current block.

func (Conf) PutHUD

func (c Conf) PutHUD(cmd string) error

PutHUD saves the upstream status line, replacing any earlier one and keeping the user's own lines.

func (Conf) QueueItems

func (c Conf) QueueItems() int

QueueItems is how many queue items a listing shows (SITREP_QUEUE_ITEMS).

func (Conf) QueueNudge added in v1.0.0

func (c Conf) QueueNudge() bool

QueueNudge says whether the hooks tell Claude how many items the session's queue holds (SITREP_QUEUE_NUDGE), so that it asks the user whether to start the next one: off unless this is 1, on, true or yes.

func (Conf) ReadBody added in v1.0.0

func (c Conf) ReadBody() (string, error)

ReadBody is the whole of sitrep.conf, as the colour tool edits it: a link is followed, a missing file is empty, and a file over 64 KB is refused.

func (Conf) StatusLines added in v1.0.0

func (c Conf) StatusLines() map[string]bool

StatusLines is the set of lines the status line shows (SITREP_STATUS_LINES): names from StatusLineNames, separated by commas or spaces, in any case. A name it does not know is ignored, and a value with no known name is the same as none, so every line shows: a typo costs a line and never blanks the status line.

func (Conf) TUIInterval added in v0.7.0

func (c Conf) TUIInterval() time.Duration

TUIInterval is the dashboard's refresh interval (SITREP_TUI_INTERVAL): a number of seconds, or a duration such as 500ms, 5s or 1m. Anything else, or a value below one second (which the dashboard would raise to one anyway), is the default.

func (Conf) Target added in v1.0.0

func (c Conf) Target() string

Target is the file a write goes to: sitrep.conf, or what a link at that path leads to.

func (Conf) Theme added in v0.6.0

func (c Conf) Theme() string

Theme is the name of the dashboard's colour theme (SITREP_THEME): lowercase letters and hyphens, or "" for the default. What it names is the dashboard's to know; a name it does not have gives the default theme.

func (Conf) WriteBody added in v1.0.0

func (c Conf) WriteBody(out, original string) error

WriteBody replaces the file with out when it still holds original, as the settings editor does (settings.ErrChanged when it does not).

Jump to

Keyboard shortcuts

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