summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/Main.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cuchaz/enigma/Main.java')
-rw-r--r--src/main/java/cuchaz/enigma/Main.java22
1 files changed, 3 insertions, 19 deletions
diff --git a/src/main/java/cuchaz/enigma/Main.java b/src/main/java/cuchaz/enigma/Main.java
index 1d63ec1..7c87669 100644
--- a/src/main/java/cuchaz/enigma/Main.java
+++ b/src/main/java/cuchaz/enigma/Main.java
@@ -17,10 +17,7 @@ import cuchaz.enigma.translation.mapping.serde.MappingFormat;
17 17
18import joptsimple.*; 18import joptsimple.*;
19 19
20import java.io.BufferedReader;
21import java.io.IOException; 20import java.io.IOException;
22import java.io.InputStreamReader;
23import java.nio.charset.StandardCharsets;
24import java.nio.file.Files; 21import java.nio.file.Files;
25import java.nio.file.Path; 22import java.nio.file.Path;
26import java.nio.file.Paths; 23import java.nio.file.Paths;
@@ -54,20 +51,7 @@ public class Main {
54 return; 51 return;
55 } 52 }
56 53
57 EnigmaProfile parsedProfile; 54 EnigmaProfile parsedProfile = EnigmaProfile.read(options.valueOf(profile));
58 if (options.has(profile)) {
59 Path profilePath = options.valueOf(profile);
60 try (BufferedReader reader = Files.newBufferedReader(profilePath)) {
61 parsedProfile = EnigmaProfile.parse(reader);
62 }
63 } else {
64 try (BufferedReader reader = new BufferedReader(new InputStreamReader(Main.class.getResourceAsStream("/profile.json"), StandardCharsets.UTF_8))){
65 parsedProfile = EnigmaProfile.parse(reader);
66 } catch (IOException ex) {
67 System.out.println("Failed to load default profile, will use empty profile: " + ex.getMessage());
68 parsedProfile = EnigmaProfile.EMPTY;
69 }
70 }
71 55
72 Gui gui = new Gui(parsedProfile); 56 Gui gui = new Gui(parsedProfile);
73 GuiController controller = gui.getController(); 57 GuiController controller = gui.getController();
@@ -95,8 +79,8 @@ public class Main {
95 } 79 }
96 } 80 }
97 81
98 private static class PathConverter implements ValueConverter<Path> { 82 public static class PathConverter implements ValueConverter<Path> {
99 static final ValueConverter<Path> INSTANCE = new PathConverter(); 83 public static final ValueConverter<Path> INSTANCE = new PathConverter();
100 84
101 PathConverter() { 85 PathConverter() {
102 } 86 }