using System.IO;
using RebootKit.Editor.Build;
using UnityEditor;
using UnityEngine;

namespace RebootKit.Editor {
    static class CommonEditorActions {
        [MenuItem(REditorConsts.k_EditorMenu + "Bump minor version", false, 0)]
        static void BumpMinorVersion() {
            if (VersionUpdater.IncrementMinor()) {
                Debug.Log("Bumped minor version.");
            } else {
                Debug.LogError("Failed to bump minor version.");
            }
        }

        [MenuItem(REditorConsts.k_EditorMenu + "Open Persistent Data Folder", false, 100)]
        static void OpenPersistentDataFolder() {
            string path = Application.persistentDataPath;
            if (Directory.Exists(path)) {
                EditorUtility.RevealInFinder(path);
            } else {
                Debug.LogError($"Persistent data folder does not exist: {path}");
            }
        }

        [MenuItem(REditorConsts.k_EditorMenu + "Remove Persistent Data Folder", false, 1000)]
        static void RemovePersistentDataFolder() {
            string path = Application.persistentDataPath;
            if (Directory.Exists(path)) {
                Directory.Delete(path, true);
                Debug.Log($"Removed persistent data folder: {path}");
            } else {
                Debug.LogError($"Persistent data folder does not exist: {path}");
            }
        }
    }
}