diff options
| author | hachem <im@hachem.wtf> | 2026-08-29 18:24:42 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-08-29 18:24:42 +0200 |
| commit | fcbbeccaa80c7e120933682b330272a1490c1cf5 (patch) | |
| tree | 11de4610f01a3861f7bbea94da63dd2d070f420a /internal/config/cache.go | |
| parent | 4806ee7ef95f0f04079856f7753399b7b7aa6330 (diff) | |
refactor: unify mods command with the search
Diffstat (limited to 'internal/config/cache.go')
| -rw-r--r-- | internal/config/cache.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/config/cache.go b/internal/config/cache.go index 825af7f..aaaa97b 100644 --- a/internal/config/cache.go +++ b/internal/config/cache.go @@ -23,6 +23,18 @@ func LoadAPI() (*API, error) { return &a, nil } +func SaveAPI(api *API) error { + if err := os.MkdirAll(Dir, 0o755); err != nil { + return err + } + + data, err := json.MarshalIndent(api, "", " ") + if err != nil { + return err + } + return os.WriteFile(APIPath(), append(data, '\n'), 0o600) +} + type ModState struct { Compatible string `json:"compatible"` Latest string `json:"latest"` |
