setting

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 9 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 setting is the list of the settings of sitrep.conf that a person may change with `sitrep config`: for each its kind and limits, the default, and a function that reads the value the program uses now, by calling the getter that the program itself calls.

Index

Constants

This section is empty.

Variables

View Source
var Settings = []Setting{
	num("SITREP_QUEUE_ITEMS", 1, 1000, conf.DefaultQueueItems, conf.Conf.QueueItems),
	{Name: "SITREP_STATUS_LINES", Kind: List, Values: conf.StatusLineNames, Default: strings.Join(conf.StatusLineNames, ","), Read: func(c conf.Conf) string {
		set := c.StatusLines()
		var on []string
		for _, n := range conf.StatusLineNames {
			if set[n] {
				on = append(on, n)
			}
		}
		return strings.Join(on, ",")
	}},
	num("SITREP_HIGHLIGHT_SECONDS", 0, 86400, conf.DefaultHighlightSeconds, conf.Conf.HighlightSeconds),
	{Name: "SITREP_HIGHLIGHT_SGR", Kind: Style, Default: conf.DefaultHighlightSGR, Read: conf.Conf.HighlightSGR},
	num("SITREP_ATTN_FADE", 0, 604800, conf.DefaultAttnFade, conf.Conf.AttnFade),
	{Name: "SITREP_DEBOUNCE", Kind: Int, Min: 0, Max: conf.MaxDebounce, Default: strconv.Itoa(conf.DefaultDebounce),
		Read: func(c conf.Conf) string { return strconv.Itoa(conf.DebounceSeconds(c.Get("SITREP_DEBOUNCE"))) }},
	sw("SITREP_CHECK_UPDATES", "on", false, conf.Conf.CheckUpdates),
	{Name: "SITREP_THEME", Kind: Owned, Owner: "sitrep colors", Default: "default", Read: func(c conf.Conf) string {
		if t := c.Theme(); t != "" {
			return t
		}
		return "default"
	}},
	{Name: "SITREP_COLORS", Kind: Owned, Owner: "sitrep colors", Default: "", Read: conf.Conf.Colors},
	{Name: "SITREP_TUI_INTERVAL", Kind: Duration, Default: "3s", Restart: true, Read: func(c conf.Conf) string { return c.TUIInterval().String() }},
	sw("SITREP_TUI_READONLY", "off", true, conf.Conf.TUIReadOnly),
	sw("SITREP_TUI_BELL", "on", true, conf.Conf.TUIBell),
	sw("SITREP_TUI_HINTS", "on", true, conf.Conf.TUIHints),
	sw("SITREP_TUI_MOUSE", "off", true, conf.Conf.TUIMouse),
	sw("SITREP_LOG", "off", false, conf.Conf.LogOn),
	num("SITREP_LOG_MAX", 1, 128, conf.DefaultLogMaxMB, conf.Conf.LogMaxMB),
	num("SITREP_LOG_DAYS", 1, 3650, conf.DefaultLogDays, conf.Conf.LogDays),
	sw("SITREP_QUEUE_NUDGE", "off", false, conf.Conf.QueueNudge),
	num("SITREP_BACKUP_WARN", 0, 3650, 2, conf.Conf.BackupWarnDays),
	{Name: "SITREP_LANG", Kind: Language, Default: "", Restart: true, Read: func(c conf.Conf) string {
		return i18n.Choose(func(n string) string {
			if n == "SITREP_LANG" {
				return c.Get(n)
			}
			return os.Getenv(n)
		})
	}},
	{Name: "SITREP_SUMMARY_LANG", Kind: Tag, Default: "", Read: func(c conf.Conf) string {
		if t, ok := conf.ParseLanguageTag(c.Get("SITREP_SUMMARY_LANG")); ok {
			return t
		}
		return ""
	}},
}

Settings are the rows, in the order of docs/SETTINGS.md where it has one.

Functions

func HelpKey

func HelpKey(name string) string

HelpKey is the catalog key of the help of a setting: setting.<name without SITREP_, in lower case>.

func Suggest

func Suggest(name string) []string

Suggest is the names that look like a name that was not found, for an error.

Types

type Kind

type Kind int

Kind says how a value is written and checked.

const (
	Switch   Kind = iota // on or off
	Int                  // digits, from Min to Max
	List                 // names from Values, separated by commas
	Duration             // seconds, or a duration such as 500ms, 5s, 1m
	Style                // terminal SGR codes: digits and semicolons
	Language             // a language of the dashboard
	Tag                  // a language tag, for the summaries
	Owned                // another command writes it; config only shows it
)

type Setting

type Setting struct {
	Name     string
	Kind     Kind
	Min, Max int                    // for Int
	Values   []string               // for List: what is accepted, and what completion offers
	Default  string                 // as text, for display
	Restart  bool                   // the dashboard reads it when it starts, so a change shows after a restart
	Owner    string                 // for Owned: the command that writes it
	Read     func(conf.Conf) string // the value the program uses now
}

Setting is one row.

func Find

func Find(name string) (Setting, bool)

Find is the row of a name. The name may be written without the SITREP_ prefix and in any case.

func (Setting) Check

func (s Setting) Check(value string) error

Check says whether value may be written for the setting, and why not. It is the only place that decides: the getters read what is in the file as they always did, and a hook never fails over it.

func (Setting) Help

func (s Setting) Help() string

Help is the one line that says what the setting does, in the language in use.

Jump to

Keyboard shortcuts

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