package me.coley.recaf.command.impl;

import me.coley.recaf.Recaf;
import me.coley.recaf.control.Controller;
import me.coley.recaf.control.gui.GuiController;
import me.coley.recaf.control.headless.HeadlessController;
import picocli.CommandLine;

import java.io.File;

/**
 * Command line initializer for Recaf, invoked from the main method.
 *
 * @author Matt
 */
@CommandLine.Command(
		name = "Recaf",
		version = Recaf.VERSION,
		description = "Recaf: A modern java bytecode editor.",
		mixinStandardHelpOptions = true)
public class Initializer implements Runnable {
	/**
	 * Workspace file to import.
	 */
	@CommandLine.Option(names = {"--input" }, description = "The input file to load. " +
			"Supported types are: class, jar, json")
	public File input;
	@CommandLine.Option(names = {"--script" }, description = "Script file to load for cli usage")
	public File script;
	@CommandLine.Option(names = { "--cli" }, description = "Run Recaf via CLI")
	public boolean cli;

	@Override
	public void run() {
		Controller controller;
		if (cli || script != null)
			controller = new HeadlessController(input, script);
		else
			controller = new GuiController(input);
		controller.setup();
		controller.run();
	}
}
@@ -239,16 +239,35 @@
 dLine;%0A%0A
+import java.awt.*;%0A
 import j
@@ -1071,16 +1071,52 @@
  != null
+ %7C%7C GraphicsEnvironment.isHeadless()
 )%0A%09%09%09con

Check if we are running in headless environment