Documentation
¶
Overview ¶
Package config handles the user configations.
nolint:goconst
Example (Recommend) ¶
color.Enable = false fmt.Print(recommend(""))
Output: (suggestion: do not use)
Example (UpdateBool) ¶
color.Enable = false updateBool(false, "example")
Output: The example is not in use.
Example (UpdateString) ¶
color.Enable = false updateString("", "example", "") updateString("x", saveDir, "")
Output: The empty example setting is not in use. The save-directory is set to "". ✗
Index ¶
- Variables
- func ColorCSS(elm string) string
- func ColorHTML(elm string) string
- func Create(name string, ow bool) error
- func CtrlC()
- func Delete() error
- func Edit() error
- func Editor() string
- func Enabled() map[string]interface{}
- func Info(style string) error
- func InitDefaults()
- func KeySort() []string
- func Keys() []string
- func List() error
- func Location() string
- func Marshal() (interface{}, error)
- func Missing() (list []string)
- func Names(lexer string) string
- func New(overwrite bool) error
- func Path() string
- func Set(name string)
- func SetConfig(flag string) error
- func Setup(start int)
- func Update(name string, setup bool)
- func UpdateConfig(name string, stdout bool) error
- func Validate(key string) (ok bool)
- type Defaults
- type Formats
- type Hints
- type Settings
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrEditorNil = errors.New("no suitable text editor can be found") ErrEditorRun = errors.New("editor cannot be run") ErrLogo = errors.New("program logo is missing") ErrSaveType = errors.New("save value type is unsupported") ErrBool = errors.New("key is not a boolean (true/false) value") ErrString = errors.New("key is not a string (text) value") ErrUint = errors.New("key is not a absolute number") )
Functions ¶
func ColorHTML ¶ added in v0.0.31
ColorHTML returns the element colored using HTML syntax highlights.
func CtrlC ¶ added in v0.0.33
func CtrlC()
CtrlC intercepts Ctrl-C key combinations to exit out of the Setup.
func Editor ¶
func Editor() string
Editor returns the path of a configured or discovered text editor.
func Enabled ¶
func Enabled() map[string]interface{}
Enabled returns all the Viper keys holding a value that are used. This will hide all unrecognized manual edits to the configuration file.
func KeySort ¶ added in v0.0.33
func KeySort() []string
KeySort list all the available configuration setting names sorted by hand.
func Keys ¶
func Keys() []string
Keys list all the available configuration setting names sorted alphabetically.
func Location ¶ added in v0.0.33
func Location() string
Location returns the absolute path of the current configuration file and the status of any missing settings.
func Marshal ¶
func Marshal() (interface{}, error)
Marshal default values for use in a YAML configuration file.
func Missing ¶
func Missing() (list []string)
Missing returns the settings that are not found in the configuration file. This could be due to new features being added after the file was generated or because of manual file edits.
func Set ¶
func Set(name string)
Set edits and saves a named setting within a configuration file. It also accepts numeric index values printed by List().
func Setup ¶
func Setup(start int)
Setup walks through all the settings and saves them to the configuration file. Start the walk through at the provided question number or leave it at 0.
func UpdateConfig ¶
UpdateConfig saves all viper settings to the named file.
Types ¶
type Settings ¶
type Settings struct { Editor string HTML struct { Font struct { Embed bool `yaml:"embed"` Family string `yaml:"family"` Size string `yaml:"size"` } Layout string `yaml:"layout"` Meta struct { Author string `yaml:"author"` ColorScheme string `yaml:"color-scheme"` Description string `yaml:"description"` Keywords string `yaml:"keywords"` Referrer string `yaml:"referrer"` Robots string `yaml:"robots"` ThemeColor string `yaml:"theme-color"` Generator bool `yaml:"generator"` Notranslate bool `yaml:"notranslate"` RetroTxt bool `yaml:"retrotxt"` } Title string `yaml:"title"` } SaveDirectory string `yaml:"save-directory"` ServerPort uint `yaml:"serve"` Style struct { Info string `yaml:"info"` HTML string `yaml:"html"` } }
Settings types and names to be saved as YAML.