Import config from file
This commit is contained in:
@@ -42,6 +42,7 @@ import com.sheepit.client.ShutdownHook;
|
||||
import com.sheepit.client.hardware.gpu.GPU;
|
||||
import com.sheepit.client.hardware.gpu.GPUDevice;
|
||||
import com.sheepit.client.network.ProxyAuthenticator;
|
||||
import com.sheepit.client.standalone.swing.SettingsLoader;
|
||||
|
||||
public class Worker {
|
||||
@Option(name = "-server", usage = "Render-farm server, default https://www.sheepit-renderfarm.com", metaVar = "URL", required = false)
|
||||
@@ -83,6 +84,9 @@ public class Worker {
|
||||
@Option(name = "-ui", usage = "Specify the user interface to use, default 'swing', available 'oneline', 'text', 'swing' (graphical)", required = false)
|
||||
private String ui_type = "swing";
|
||||
|
||||
@Option(name = "-config", usage = "Specify the configuration file", required = false)
|
||||
private String config_file = null;
|
||||
|
||||
@Option(name = "--version", usage = "Display application version", required = false, handler = VersionParameterHandler.class)
|
||||
private VersionParameterHandler versionHandler;
|
||||
|
||||
@@ -257,6 +261,16 @@ public class Worker {
|
||||
|
||||
config.setComputeMethod(compute_method);
|
||||
|
||||
|
||||
if (config_file != null) {
|
||||
if (new File(config_file).exists() == false) {
|
||||
System.err.println("Configuration file not found.");
|
||||
System.err.println("Aborting");
|
||||
System.exit(2);
|
||||
}
|
||||
new SettingsLoader(config_file).merge(config);
|
||||
}
|
||||
|
||||
Log.getInstance(config).debug("client version " + config.getJarVersion());
|
||||
|
||||
Gui gui;
|
||||
|
||||
@@ -24,11 +24,15 @@ public class SettingsLoader {
|
||||
private String autoSignIn;
|
||||
|
||||
public SettingsLoader() {
|
||||
generateFilePath();
|
||||
path = getDefaultFilePath();
|
||||
}
|
||||
|
||||
public SettingsLoader(String path_) {
|
||||
path = path_;
|
||||
}
|
||||
|
||||
public SettingsLoader(String login_, String password_, ComputeType computeMethod_, GPUDevice gpu_, String cacheDir_, boolean autoSignIn_) {
|
||||
generateFilePath();
|
||||
path = getDefaultFilePath();
|
||||
login = login_;
|
||||
password = password_;
|
||||
cacheDir = cacheDir_;
|
||||
@@ -47,8 +51,8 @@ public class SettingsLoader {
|
||||
}
|
||||
}
|
||||
|
||||
private void generateFilePath() {
|
||||
path = System.getProperty("user.home") + File.separator + ".sheepit.conf";
|
||||
public static String getDefaultFilePath() {
|
||||
return System.getProperty("user.home") + File.separator + ".sheepit.conf";
|
||||
}
|
||||
|
||||
public String getFilePath() {
|
||||
|
||||
Reference in New Issue
Block a user