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
- Variables
- func Quote(s string) string
- func Unquote(s string) string
- type Conf
- func (c Conf) CheckUpdates() bool
- func (c Conf) Colors() string
- func (c Conf) DropExamples() error
- func (c Conf) DropHUD() error
- func (c Conf) FromFile(name string) string
- func (c Conf) Get(name string) string
- func (c Conf) HighlightSGR() string
- func (c Conf) HighlightSeconds() int
- func (c Conf) PutExamples() error
- func (c Conf) PutHUD(cmd string) error
- func (c Conf) QueueItems() int
- func (c Conf) TUIInterval() time.Duration
- func (c Conf) Theme() string
Constants ¶
const ( DefaultQueueItems = 5 DefaultHighlightSeconds = 60 DefaultHighlightSGR = "48;5;238" )
Defaults of the settings that have one.
const DefaultTUIInterval = 3 * time.Second
DefaultTUIInterval is how often the dashboard refreshes when nothing says otherwise.
const Examples = `` /* 1473-byte string literal not displayed */
Examples is the text of the block: every setting, commented out, with its default.
const MaxColors = 300
MaxColors is the longest SITREP_COLORS the dashboard is given.
Variables ¶
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.
Functions ¶
Types ¶
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 (Conf) CheckUpdates ¶ added in v0.6.0
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
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
DropExamples removes the block. The file goes when nothing else is left.
func (Conf) DropHUD ¶
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 ¶
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 ¶
Get returns a setting: the environment wins, then the first NAME=value line of the file. It is empty when unset.
func (Conf) HighlightSGR ¶
HighlightSGR is the terminal style of the highlight. Only digits and semicolons are accepted, because the value reaches the terminal.
func (Conf) HighlightSeconds ¶
HighlightSeconds is how long a session counts as recently active (SITREP_HIGHLIGHT_SECONDS); 0 turns the highlight off.
func (Conf) PutExamples ¶ added in v0.7.0
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 ¶
PutHUD saves the upstream status line, replacing any earlier one and keeping the user's own lines.
func (Conf) QueueItems ¶
QueueItems is how many queue items a listing shows (SITREP_QUEUE_ITEMS).
func (Conf) TUIInterval ¶ added in v0.7.0
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.