mirror of
https://github.com/cheat/cheat.git
synced 2026-03-07 03:03:32 +01:00
- Remove unused parameters, dead files, and inaccurate doc.go files - Extract shared helpers, eliminate duplication - Rename cheatpath.Cheatpath to cheatpath.Path - Optimize filesystem walks (WalkDir, skip .git) - Move sheet name validation to sheet.Validate - Move integration tests to test/integration/ - Consolidate internal/mock into mocks/ - Move fuzz.sh to test/ - Inline loadSheets helper into command callers - Extract config.New into its own file - Fix stale references in HACKING.md and CLAUDE.md - Restore plan9 build target - Remove redundant and low-value tests - Clean up project documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
23 lines
572 B
Go
23 lines
572 B
Go
package cheatpath
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// Writeable returns a writeable Path
|
|
func Writeable(cheatpaths []Path) (Path, error) {
|
|
|
|
// iterate backwards over the cheatpaths
|
|
// NB: we're going backwards because we assume that the most "local"
|
|
// cheatpath will be specified last in the configs
|
|
for i := len(cheatpaths) - 1; i >= 0; i-- {
|
|
// if the cheatpath is not read-only, it is writeable, and thus returned
|
|
if !cheatpaths[i].ReadOnly {
|
|
return cheatpaths[i], nil
|
|
}
|
|
}
|
|
|
|
// otherwise, return an error
|
|
return Path{}, fmt.Errorf("no writeable cheatpaths found")
|
|
}
|