import { Loader } from "../types/mcgrizzconf.ts";

export const getServerStartCommands = (
  loader: Loader,
  instance = "server",
): Deno.Command => {
  switch (loader) {
    case "forge":
      return Deno.build.os === "windows"
        ? new Deno.Command(
          "cmd.exe",
          {
            args: [
              "./run.bat",
              "nogui",
            ],
            stdin: "piped",
            stdout: "piped",
            cwd: "./" + instance,
          },
        )
        : new Deno.Command(
          "./run.sh",
          {
            args: [
              "nogui",
            ],
            stdin: "piped",
            stdout: "piped",
            cwd: "./" + instance,
          },
        );
    case "vanilla":
    case "unset":
    case "fabric":
      return new Deno.Command("java", {
        args: [
          "-Xmx8G",
          "-jar",
          "./server.jar",
          "nogui",
        ],
        cwd: "./" + instance,
        stdin: "piped",
        stdout: "piped",
      });
  }
};
