summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/Main.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuchaz/enigma/Main.java')
-rw-r--r--src/cuchaz/enigma/Main.java41
1 files changed, 16 insertions, 25 deletions
diff --git a/src/cuchaz/enigma/Main.java b/src/cuchaz/enigma/Main.java
index 73a12db..f8d3afe 100644
--- a/src/cuchaz/enigma/Main.java
+++ b/src/cuchaz/enigma/Main.java
@@ -14,46 +14,37 @@ import java.io.File;
14 14
15import cuchaz.enigma.gui.Gui; 15import cuchaz.enigma.gui.Gui;
16 16
17public class Main 17public class Main {
18{ 18
19 public static void main( String[] args ) 19 public static void main(String[] args) throws Exception {
20 throws Exception
21 {
22 Gui gui = new Gui(); 20 Gui gui = new Gui();
23 21
24 // parse command-line args 22 // parse command-line args
25 if( args.length >= 1 ) 23 if (args.length >= 1) {
26 { 24 gui.getController().openJar(getFile(args[0]));
27 gui.getController().openJar( getFile( args[0] ) );
28 } 25 }
29 if( args.length >= 2 ) 26 if (args.length >= 2) {
30 { 27 gui.getController().openMappings(getFile(args[1]));
31 gui.getController().openMappings( getFile( args[1] ) );
32 } 28 }
33 29
34 // DEBUG 30 // DEBUG
35 //gui.getController().openDeclaration( new ClassEntry( "none/ces" ) ); 31 // gui.getController().openDeclaration( new ClassEntry( "none/ces" ) );
36 } 32 }
37 33
38 private static File getFile( String path ) 34 private static File getFile(String path) {
39 {
40 // expand ~ to the home dir 35 // expand ~ to the home dir
41 if( path.startsWith( "~" ) ) 36 if (path.startsWith("~")) {
42 {
43 // get the home dir 37 // get the home dir
44 File dirHome = new File( System.getProperty( "user.home" ) ); 38 File dirHome = new File(System.getProperty("user.home"));
45 39
46 // is the path just ~/ or is it ~user/ ? 40 // is the path just ~/ or is it ~user/ ?
47 if( path.startsWith( "~/" ) ) 41 if (path.startsWith("~/")) {
48 { 42 return new File(dirHome, path.substring(2));
49 return new File( dirHome, path.substring( 2 ) ); 43 } else {
50 } 44 return new File(dirHome.getParentFile(), path.substring(1));
51 else
52 {
53 return new File( dirHome.getParentFile(), path.substring( 1 ) );
54 } 45 }
55 } 46 }
56 47
57 return new File( path ); 48 return new File(path);
58 } 49 }
59} 50}