diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/Main.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/Main.java | 22 |
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 | ||
| 18 | import joptsimple.*; | 18 | import joptsimple.*; |
| 19 | 19 | ||
| 20 | import java.io.BufferedReader; | ||
| 21 | import java.io.IOException; | 20 | import java.io.IOException; |
| 22 | import java.io.InputStreamReader; | ||
| 23 | import java.nio.charset.StandardCharsets; | ||
| 24 | import java.nio.file.Files; | 21 | import java.nio.file.Files; |
| 25 | import java.nio.file.Path; | 22 | import java.nio.file.Path; |
| 26 | import java.nio.file.Paths; | 23 | import 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 | } |