initial commit

This commit is contained in:
2026-01-04 21:26:49 +01:00
commit 8e83c99620
12 changed files with 11958 additions and 0 deletions

38
internal/gamelist.go Normal file
View File

@@ -0,0 +1,38 @@
package oplcli
import (
"bufio"
"fmt"
"os"
"strings"
)
func loadGamelist(filepath string) (map[string]string, error) {
file, err := os.Open(filepath)
if err != nil {
return nil, fmt.Errorf("Failed to open file: %w", err)
}
defer file.Close()
gameList := make(map[string]string)
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := scanner.Text()
substrings := strings.SplitN(line, " ", 2)
if len(substrings) != 2 {
// TODO: something in the gamelist file is not formatted right
fmt.Printf("Malformed: %s\n", line)
continue
}
key := substrings[0]
value := substrings[1]
gameList[key] = value
}
return gameList, nil
}