MCPcopy
hub / github.com/cheat/cheat / loadConfig

Function loadConfig

internal/completions/config.go:14–38  ·  view source on GitHub ↗

loadConfig loads the cheat configuration for use in completion functions. It returns an error rather than exiting, since completions should degrade gracefully.

()

Source from the content-addressed store, hash-verified

12// It returns an error rather than exiting, since completions should degrade
13// gracefully.
14func loadConfig() (config.Config, error) {
15 home, err := homedir.Dir()
16 if err != nil {
17 return config.Config{}, err
18 }
19
20 envvars := config.EnvVars()
21
22 confpaths, err := config.Paths(runtime.GOOS, home, envvars)
23 if err != nil {
24 return config.Config{}, err
25 }
26
27 confpath, err := config.Path(confpaths)
28 if err != nil {
29 return config.Config{}, err
30 }
31
32 conf, err := config.New(confpath, true)
33 if err != nil {
34 return config.Config{}, err
35 }
36
37 return conf, nil
38}

Callers 3

TagsFunction · 0.85
PathsFunction · 0.85
CheatsheetsFunction · 0.85

Calls 4

EnvVarsFunction · 0.92
PathsFunction · 0.92
PathFunction · 0.92
NewFunction · 0.92

Tested by

no test coverage detected