From c14d5866e66165dfb8af807f6c13df60302f14ae Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Wed, 29 Jun 2022 21:20:42 +0200 Subject: [PATCH] remove App class --- src/main/java/Bootstrapper.java | 5 +++-- .../java/net/horizoncode/sysbackup/App.java | 17 ----------------- .../horizoncode/sysbackup/cli/CLIProcessor.java | 3 +-- .../horizoncode/sysbackup/config/Config.java | 6 ++---- 4 files changed, 6 insertions(+), 25 deletions(-) delete mode 100644 src/main/java/net/horizoncode/sysbackup/App.java diff --git a/src/main/java/Bootstrapper.java b/src/main/java/Bootstrapper.java index 17a925c..28a4375 100644 --- a/src/main/java/Bootstrapper.java +++ b/src/main/java/Bootstrapper.java @@ -1,8 +1,9 @@ -import net.horizoncode.sysbackup.App; +import net.horizoncode.sysbackup.cli.CLIProcessor; public class Bootstrapper { public static void main(String[] args) { - App.getInstance().start(args); + CLIProcessor cliProcessor = new CLIProcessor(); + cliProcessor.startCLI(args); } } diff --git a/src/main/java/net/horizoncode/sysbackup/App.java b/src/main/java/net/horizoncode/sysbackup/App.java deleted file mode 100644 index 7d5f77c..0000000 --- a/src/main/java/net/horizoncode/sysbackup/App.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.horizoncode.sysbackup; - -import net.horizoncode.sysbackup.cli.CLIProcessor; - -public class App { - private static App instance; - - public static App getInstance() { - if (instance != null) return instance; - return instance = new App(); - } - - public void start(String[] args){ - CLIProcessor cliProcessor = new CLIProcessor(); - cliProcessor.startCLI(args); - } -} diff --git a/src/main/java/net/horizoncode/sysbackup/cli/CLIProcessor.java b/src/main/java/net/horizoncode/sysbackup/cli/CLIProcessor.java index 62e4dbc..5b3ff6b 100644 --- a/src/main/java/net/horizoncode/sysbackup/cli/CLIProcessor.java +++ b/src/main/java/net/horizoncode/sysbackup/cli/CLIProcessor.java @@ -1,6 +1,5 @@ package net.horizoncode.sysbackup.cli; -import net.horizoncode.sysbackup.App; import net.horizoncode.sysbackup.config.Config; import net.horizoncode.sysbackup.tasks.TaskBuilder; import org.apache.commons.io.FileUtils; @@ -73,7 +72,7 @@ public class CLIProcessor { if (!tasksFolder.mkdir()) System.err.println("Failed to create tasks folder!"); System.out.println("Saving task config " + fileName + ".toml..."); FileUtils.copyInputStreamToFile( - Objects.requireNonNull(App.class.getResourceAsStream("/" + "exampletask.toml")), + Objects.requireNonNull(getClass().getResourceAsStream("/" + "exampletask.toml")), new File(tasksFolder, fileName + ".toml")); System.out.println(fileName + ".toml saved!"); break; diff --git a/src/main/java/net/horizoncode/sysbackup/config/Config.java b/src/main/java/net/horizoncode/sysbackup/config/Config.java index 1e063ef..0881e3d 100644 --- a/src/main/java/net/horizoncode/sysbackup/config/Config.java +++ b/src/main/java/net/horizoncode/sysbackup/config/Config.java @@ -1,8 +1,6 @@ package net.horizoncode.sysbackup.config; -import lombok.AccessLevel; import lombok.Getter; -import net.horizoncode.sysbackup.App; import org.apache.commons.io.FileUtils; import org.tomlj.Toml; import org.tomlj.TomlArray; @@ -26,7 +24,7 @@ public class Config { if (!configFile.exists()) { try { FileUtils.copyInputStreamToFile( - Objects.requireNonNull(App.class.getResourceAsStream("/" + configFile.getName())), + Objects.requireNonNull(getClass().getResourceAsStream("/" + configFile.getName())), configFile); justCreated = true; } catch (IOException e) { @@ -36,7 +34,7 @@ public class Config { if (configFile.isDirectory()) { try { FileUtils.copyInputStreamToFile( - Objects.requireNonNull(App.class.getResourceAsStream("/" + configFile.getName())), + Objects.requireNonNull(getClass().getResourceAsStream("/" + configFile.getName())), configFile); justCreated = true; } catch (IOException e) {