refactor(commands): separate commands and its core into two folders (#32)

- I think it would be better if one for commands only, one for the spec
handling core logic so people won't be confused by the core logic inside
the commands folder (cleaner I guess)
- Regen docs
This commit is contained in:
VERSE
2026-07-05 11:27:30 +07:00
committed by GitHub
parent 6b98455957
commit ebde9ba68f
536 changed files with 2241 additions and 2241 deletions
+38
View File
@@ -0,0 +1,38 @@
package spec
import (
"os"
"path/filepath"
"sync"
)
var (
pathCmds = make(map[string]bool)
pathCmdsOnce sync.Once
)
// scanExternalCommands populates pathCmds with system executables
func scanExternalCommands() {
pathCmdsOnce.Do(func() {
scanPath()
})
}
// scanPath populates pathCmds with all executable files found in path environment variable
func scanPath() {
dirs := filepath.SplitList(os.Getenv("PATH"))
for _, dir := range dirs {
files, err := os.ReadDir(dir)
if err != nil {
continue
}
for _, f := range files {
if !f.IsDir() {
info, err := f.Info()
if err == nil && info.Mode()&0111 != 0 {
pathCmds[f.Name()] = true
}
}
}
}
}