Documentation ¶
Index ¶
- Constants
- func Copy(src, dest string) error
- func CreateFile(fileName string) (string, error)
- func Initialize(hasCustom bool)
- func LoadWtfConfigFile(filePath string) *config.Config
- func NewDefaultColorConfig() (*config.Config, error)
- func ParseAsMapOrList(ymlConfig *config.Config, configKey string) []string
- func ParseTimeString(cfg *config.Config, configKey string, defaultValue string) time.Duration
- func StoreSecret(globalConfig *config.Config, secret *Secret) error
- func WtfConfigDir() (string, error)
- type BorderTheme
- type CheckboxTheme
- type ColorTheme
- type Common
- func (common *Common) DefaultFocusedRowColor() string
- func (common *Common) DefaultRowColor() string
- func (common *Common) FocusChar() string
- func (common *Common) LocalizedPrinter() (*message.Printer, error)
- func (common *Common) PaginationMarker(length, pos, width int) string
- func (common *Common) RightAlignFormat(width int) string
- func (common *Common) RowColor(idx int) string
- func (common *Common) SetDocumentationPath(path string)
- func (common *Common) Validations() []Validatable
- type Module
- type PositionSettings
- type RowTheme
- type Secret
- type SecretLoadParams
- type Sigils
- type TextTheme
- type Validatable
- type Validations
- type WidgetTheme
Constants ¶
const ( // XdgConfigDir defines the path to the minimal XDG-compatible configuration directory XdgConfigDir = "~/.config/" // WtfConfigDirV1 defines the path to the first version of configuration. Do not use this WtfConfigDirV1 = "~/.wtf/" // WtfConfigDirV2 defines the path to the second version of the configuration. Use this. WtfConfigDirV2 = "~/.config/wtf/" // WtfConfigFile defines the name of the default config file WtfConfigFile = "config.yml" )
Variables ¶
This section is empty.
Functions ¶
func CreateFile ¶
CreateFile creates the named file in the config directory, if it does not already exist. If the file exists it does not recreate it. If successful, returns the absolute path to the file If unsuccessful, returns an error
func Initialize ¶
func Initialize(hasCustom bool)
Initialize takes care of settings up the initial state of WTF configuration It ensures necessary directories and files exist
func LoadWtfConfigFile ¶
LoadWtfConfigFile loads the specified config file
func NewDefaultColorConfig ¶
NewDefaultColorConfig creates and returns a config.Config-compatible configuration struct using a DefaultColorTheme to pre-populate all the relevant values
func ParseAsMapOrList ¶
ParseAsMapOrList takes a configuration key and attempts to parse it first as a map and then as a list. Map entries are concatenated as "key/value"
func ParseTimeString ¶
ParseTimeString takes a configuration key and attempts to parse it first as an int and then as a duration (int + time unit)
func WtfConfigDir ¶
WtfConfigDir returns the absolute path to the configuration directory
Types ¶
type BorderTheme ¶
BorderTheme defines the default color scheme for drawing widget borders
type CheckboxTheme ¶
type CheckboxTheme struct {
Checked string
}
CheckboxTheme defines the default color scheme for drawing checkable rows in widgets
type ColorTheme ¶
type ColorTheme struct { BorderTheme CheckboxTheme RowTheme TextTheme WidgetTheme }
ColorTheme is an alamgam of all the default color settings
func NewDefaultColorTheme ¶
func NewDefaultColorTheme() ColorTheme
NewDefaultColorTheme creates and returns an instance of DefaultColorTheme
type Common ¶
type Common struct { Module PositionSettings `help:"Defines where in the grid this module�s widget will be displayed."` Sigils Colors ColorTheme Config *config.Config DocPath string Bordered bool `help:"Whether or not the module should be displayed with a border." values:"true, false" optional:"true" default:"true"` Enabled bool `` /* 134-byte string literal not displayed */ Focusable bool `help:"Whether or not this module is focusable." values:"true, false" optional:"true" default:"false"` LanguageTag string `` /* 127-byte string literal not displayed */ RefreshInterval time.Duration `` /* 185-byte string literal not displayed */ Title string `help:"The title string to show when displaying this module" optional:"true"` // contains filtered or unexported fields }
Common defines a set of common configuration settings applicable to all modules
func NewCommonSettingsFromModule ¶
func NewCommonSettingsFromModule(name, defaultTitle string, defaultFocusable bool, moduleConfig *config.Config, globalConfig *config.Config) *Common
NewCommonSettingsFromModule returns a common settings configuration tailed to the given module
func (*Common) DefaultFocusedRowColor ¶
func (*Common) DefaultRowColor ¶
func (*Common) FocusChar ¶
FocusChar returns the keyboard number assigned to the widget used to give onscreen focus to this widget, as a string. Focus characters can be a range between 1 and 9
func (*Common) LocalizedPrinter ¶
LocalizedPrinter returns a message.Printer instance localized to the BCP 47 language configuration value defined in 'wtf.language' config. If none exists, it defaults to 'en-CA'. Use this to format numbers, etc.
func (*Common) PaginationMarker ¶
PaginationMarker generates the pagination indicators that appear in the top-right corner of multisource widgets
func (*Common) RightAlignFormat ¶
func (*Common) SetDocumentationPath ¶
SetDocumentationPath is used to explicitly set the documentation path that should be opened when the key to open the documentation is pressed. Setting this is probably not necessary unless the module documentation is nested inside a documentation subdirectory in the /wtfutildocs repo, or the module here has a different name than the module's display name in the documentation (which ideally wouldn't be a thing).
func (*Common) Validations ¶
func (common *Common) Validations() []Validatable
Validations aggregates all the validations from all the sub-sections in Common into a single array of validations
type PositionSettings ¶
type PositionSettings struct { Validations *Validations Height int Left int Top int Width int }
PositionSettings represents the onscreen location of a widget
func NewPositionSettingsFromYAML ¶
func NewPositionSettingsFromYAML(moduleConfig *config.Config) PositionSettings
NewPositionSettingsFromYAML creates and returns a new instance of cfg.Position
type RowTheme ¶
type RowTheme struct { EvenBackground string EvenForeground string OddBackground string OddForeground string HighlightedBackground string HighlightedForeground string }
RowTheme defines the default color scheme for row text
type Secret ¶
func FetchSecret ¶
Fetch secret for `service`. Service is customarily a URL, but can be any identifier uniquely used by wtf to identify the service, such as the name of the module. nil is returned if the secretStore global property is not present or the secret is not found in that store.
type SecretLoadParams ¶
type SecretLoadParams struct {
// contains filtered or unexported fields
}
func ModuleSecret ¶
func ModuleSecret(name string, globalConfig *config.Config, secret *string) *SecretLoadParams
Load module secrets.
The credential helpers impose this structure:
SERVICE is mapped to a SECRET and USERNAME
Only SECRET is secret, SERVICE and USERNAME are not, so this API doesn't expose USERNAME.
SERVICE was intended to be the URL of an API server, but for hosted services that do not have or need a configurable API server, its easier to just use the module name as the SERVICE:
cfg.ModuleSecret(name, globalConfig, &settings.apiKey).Load() The user will use the module name as the service, and the API key as the secret, for example: % wtfutil save-secret circleci Secret: ...
If a module (such as pihole, jenkins, or github) might have multiple instantiations each using a different API service (with its own unique API key), then the module should use the API URL to lookup the secret. For example, for github:
cfg.ModuleSecret(name, globalConfig, &settings.apiKey). Service(settings.baseURL). Load()
The user will use the API URL as the service, and the API key as the secret, for example, with github configured as:
-- config.yml mods: github: baseURL: "https://github.mycompany.com/api/v3" ... the secret must be saved as: % wtfutil save-secret https://github.mycompany.com/api/v3 Secret: ... If baseURL is not set in the configuration it will be the modules default, and the SERVICE will default to the module name, "github", and the user must save the secret as: % wtfutil save-secret github Secret: ... Ideally, the individual module documentation would describe the SERVICE name to use to save the secret.
func (*SecretLoadParams) Load ¶
func (slp *SecretLoadParams) Load()
func (*SecretLoadParams) Service ¶
func (slp *SecretLoadParams) Service(service string) *SecretLoadParams
type Validatable ¶
Validatable is implemented by any value that validates a configuration setting
type Validations ¶
type Validations struct {
// contains filtered or unexported fields
}
Validations represent a collection of config setting validations
func NewValidations ¶
func NewValidations() *Validations
NewValidations creates and returns an instance of Validations
type WidgetTheme ¶
type WidgetTheme struct {
Background string
}
WidgetTheme defines the default color scheme for the widget rect itself