From 4be005617b3b8c3578cca07c5d085d12916f0d1d Mon Sep 17 00:00:00 2001 From: lclc98 Date: Thu, 30 Jun 2016 00:49:21 +1000 Subject: Json format (#2) * Added new format * Fixed bug * Updated Version --- src/main/java/cuchaz/enigma/Main.java | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/main/java/cuchaz/enigma/Main.java (limited to 'src/main/java/cuchaz/enigma/Main.java') diff --git a/src/main/java/cuchaz/enigma/Main.java b/src/main/java/cuchaz/enigma/Main.java new file mode 100644 index 0000000..68959aa --- /dev/null +++ b/src/main/java/cuchaz/enigma/Main.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2015 Jeff Martin. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser General Public + * License v3.0 which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl.html + *
+ * Contributors: + * Jeff Martin - initial API and implementation + ******************************************************************************/ +package cuchaz.enigma; + +import java.io.File; +import java.util.jar.JarFile; + +import cuchaz.enigma.gui.Gui; + +public class Main { + + public static void main(String[] args) throws Exception { + Gui gui = new Gui(); + + // parse command-line args + if (args.length >= 1) { + gui.getController().openJar(new JarFile(getFile(args[0]))); + } + if (args.length >= 2) { + gui.getController().openMappings(getFile(args[1])); + } + + // DEBUG + //gui.getController().openDeclaration(new ClassEntry("none/bxq")); + } + + private static File getFile(String path) { + // expand ~ to the home dir + if (path.startsWith("~")) { + // get the home dir + File dirHome = new File(System.getProperty("user.home")); + + // is the path just ~/ or is it ~user/ ? + if (path.startsWith("~/")) { + return new File(dirHome, path.substring(2)); + } else { + return new File(dirHome.getParentFile(), path.substring(1)); + } + } + + return new File(path); + } +} -- cgit v1.2.3