package tech.nevets.jaml;

import com.google.gson.*;

import java.io.*;
import java.nio.file.Path;

public class Profiles {
    private static final Path profilePath = Path.of(JAML.path + "\\profiles\\");

    public static void createProfile(String profileName) throws IOException {
        Writer writer = new FileWriter(profilePath + "\\" + profileName + ".json");
        String jsonString = "{}";

        GsonBuilder builder = new GsonBuilder();
        builder.setPrettyPrinting();

        Gson gson = builder.create();
        Profile profile = gson.fromJson(jsonString, Profile.class);
        System.out.println(profile);

        jsonString = gson.toJson(profile);
        System.out.println(jsonString);
        writer.write(jsonString);
    }

    public static void loadProfile(String profileName) throws FileNotFoundException {
        BufferedReader reader = new BufferedReader(new FileReader(profilePath + "\\" + profileName + ".json"));
        Profile profile = new Gson().fromJson(reader, Profile.class);

        System.out.println(profile.getProfileName());
    }
}
