MCPcopy Index your code
hub / github.com/cheat/cheat / cmdInit

Function cmdInit

cmd/cheat/cmd_init.go:13–30  ·  view source on GitHub ↗

cmdInit displays an example config file.

(home string, envvars map[string]string)

Source from the content-addressed store, hash-verified

11
12// cmdInit displays an example config file.
13func cmdInit(home string, envvars map[string]string) {
14
15 // identify the os-specific paths at which configs may be located
16 confpaths, err := config.Paths(runtime.GOOS, home, envvars)
17 if err != nil {
18 fmt.Fprintf(os.Stderr, "failed to read config paths: %v\n", err)
19 os.Exit(1)
20 }
21
22 confpath := confpaths[0]
23
24 // expand template placeholders and comment out community cheatpath
25 configs := installer.ExpandTemplate(configs(), confpath)
26 configs = installer.CommentCommunity(configs, confpath)
27
28 // output the templated configs
29 fmt.Println(configs)
30}

Callers 1

runFunction · 0.85

Calls 4

PathsFunction · 0.92
ExpandTemplateFunction · 0.92
CommentCommunityFunction · 0.92
configsFunction · 0.85

Tested by

no test coverage detected