remove App class

This commit is contained in:
HorizonCode 2022-06-29 21:20:42 +02:00
parent 37f64392da
commit c14d5866e6
4 changed files with 6 additions and 25 deletions

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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) {