Files
chenxiangtong 3ff2454c63 feat: 重构
2026-05-28 17:37:57 +08:00

40 lines
729 B
Go

package main
import (
"os"
"path/filepath"
tea "github.com/charmbracelet/bubbletea"
)
type versionInfo struct {
name string
path string
}
type versionsFoundMsg []versionInfo
type scanErrorMsg struct{ err error }
func scanVersions(exeDir string) tea.Cmd {
return func() tea.Msg {
pattern := filepath.Join(exeDir, ".minecraft", "versions", "*")
matches, err := filepath.Glob(pattern)
if err != nil {
return scanErrorMsg{err: err}
}
var versions []versionInfo
for _, m := range matches {
info, err := os.Stat(m)
if err != nil || !info.IsDir() {
continue
}
versions = append(versions, versionInfo{
name: filepath.Base(m),
path: m,
})
}
return versionsFoundMsg(versions)
}
}