first alpha version cli

This commit is contained in:
2025-05-10 21:52:52 +02:00
parent f791b7085c
commit 2380a36271
8 changed files with 275 additions and 12 deletions

View File

@@ -42,6 +42,11 @@ func Add(name, path string) (Metadata, error) {
Path: path,
}
err := os.MkdirAll(filepath.Join(datastorepath, m.ID), 0740)
if err != nil {
panic("cannot make directory for the game:" + err.Error())
}
f, err := os.OpenFile(filepath.Join(datastorepath, m.ID, "metadata.json"), os.O_CREATE|os.O_WRONLY, 0740)
if err != nil {
return Metadata{}, fmt.Errorf("cannot open the metadata file in the datastore: %w", err)
@@ -84,3 +89,11 @@ func All() ([]Metadata, error) {
func DatastorePath() string {
return datastorepath
}
func Remove(gameID string) error {
err := os.RemoveAll(filepath.Join(datastorepath, gameID))
if err != nil {
return err
}
return nil
}