package tech.nevets.tvpn;

import com.formdev.flatlaf.FlatDarkLaf;
import tech.nevets.jconf.JsonConfig;
import tech.nevets.tvpn.ui.UIManager;

import javax.swing.*;
import java.io.File;

import tech.nevets.tvpn.cli.CommandBrigadier;

public class Main {
    private static final Logger LOGGER = new Logger(Main.class);
    public static void main(String[] args) {
        LogOutputStream logOut = new LogOutputStream();
        Logger.loadLogOutStream(logOut);

        JsonConfig conf = new JsonConfig("config.json");

        if (args.length > 0) {
            new CommandBrigadier().execute(args);
        }

        try {
            javax.swing.UIManager.setLookAndFeel(new FlatDarkLaf());
        } catch (UnsupportedLookAndFeelException e) {
            LOGGER.error(e.getMessage());
        }

        File f = new File(Utils.APP_DIR + "/logs/");
        if (!f.exists()) f.mkdirs();

        UIManager uim = new UIManager(logOut);
        uim.startLoginFrame();

        //WireGuardJNI wgjni = new WireGuardJNI();
        //System.out.println(wgjni.createTunnel("test"));
        //System.out.println(wgjni.removeTunnel("test"));
    }
}
