package io.gitlab.jfronny.inceptum.cli; import io.gitlab.jfronny.inceptum.Inceptum; import io.gitlab.jfronny.inceptum.InceptumGui; import io.gitlab.jfronny.inceptum.model.inceptum.CommandArguments; import io.gitlab.jfronny.inceptum.model.inceptum.UpdateInfo; import io.gitlab.jfronny.inceptum.util.Utils; import io.gitlab.jfronny.inceptum.windows.MainWindow; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; public class GuiCommand extends Command { public GuiCommand() { super("Displays the Inceptum UI", "gui", "show"); } @Override public void invoke(CommandArguments args) { Inceptum.IS_GUI = true; UpdateInfo update = UpdateCheckCommand.getUpdate(); InceptumGui.main(args, () -> { if (update == null) { InceptumGui.WINDOWS.add(new MainWindow()); } else if (args.wrapped) { Inceptum.showOkCancel("An update was found. Should it be installed automatically?", "Update found", () -> { try { UpdateCheckCommand.update(update, true); InceptumGui.exit(); } catch (IOException | URISyntaxException e) { Inceptum.showError("Could not download update", e); } }, () -> InceptumGui.WINDOWS.add(new MainWindow())); } else { Inceptum.showOkCancel("An update was found. Automatic installs are not supported without the wrapper but you can download it nonetheless", "Update found", () -> { try { Utils.openWebBrowser(new URI(update.url())); InceptumGui.exit(); } catch (URISyntaxException e) { Inceptum.showError("Could not download update", e); } }, () -> InceptumGui.WINDOWS.add(new MainWindow())); } }); } @Override public boolean enableLog() { return true; } }