aboutsummaryrefslogtreecommitdiff
path: root/internal/object/item_store.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/object/item_store.go')
-rw-r--r--internal/object/item_store.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/object/item_store.go b/internal/object/item_store.go
index 6d62143..9e932ba 100644
--- a/internal/object/item_store.go
+++ b/internal/object/item_store.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
+ "strings"
"gopkg.in/yaml.v3"
)
@@ -36,3 +37,24 @@ func (s *ItemStore) Load(id string) (*ItemDef, error) {
s.cache[id] = &def
return &def, nil
}
+
+func (s *ItemStore) LoadAll() ([]*ItemDef, error) {
+ dir := filepath.Join(s.dataDir, "items")
+ entries, err := os.ReadDir(dir)
+ if err != nil {
+ return nil, err
+ }
+ var defs []*ItemDef
+ for _, e := range entries {
+ if e.IsDir() || filepath.Ext(e.Name()) != ".yaml" {
+ continue
+ }
+ id := strings.TrimSuffix(e.Name(), ".yaml")
+ def, err := s.Load(id)
+ if err != nil {
+ continue
+ }
+ defs = append(defs, def)
+ }
+ return defs, nil
+}