MCPcopy
hub / github.com/cheat/cheat / findLocalCheatpath

Function findLocalCheatpath

internal/config/new.go:135–147  ·  view source on GitHub ↗

findLocalCheatpath walks upward from dir looking for a .cheat directory. It returns the path to the first .cheat directory found, or an empty string if none exists. This mirrors the discovery pattern used by git for .git directories.

(dir string)

Source from the content-addressed store, hash-verified

133// if none exists. This mirrors the discovery pattern used by git for .git
134// directories.
135func findLocalCheatpath(dir string) string {
136 for {
137 candidate := filepath.Join(dir, ".cheat")
138 if info, err := os.Stat(candidate); err == nil && info.IsDir() {
139 return candidate
140 }
141 parent := filepath.Dir(dir)
142 if parent == dir {
143 return ""
144 }
145 dir = parent
146 }
147}

Calls

no outgoing calls