|
@@ -23,7 +23,9 @@
|
23
|
23
|
package com.dmdirc.commandline;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.Main;
|
|
26
|
+import com.dmdirc.ServerManager;
|
26
|
27
|
import com.dmdirc.commandparser.commands.global.NewServer;
|
|
28
|
+import com.dmdirc.config.Identity;
|
27
|
29
|
import com.dmdirc.config.IdentityManager;
|
28
|
30
|
import com.dmdirc.logger.ErrorLevel;
|
29
|
31
|
import com.dmdirc.logger.Logger;
|
|
@@ -60,7 +62,7 @@ public class CommandLineParser {
|
60
|
62
|
};
|
61
|
63
|
|
62
|
64
|
/** A list of addresses to autoconnect to. */
|
63
|
|
- private final List<URI> addresses = new ArrayList<URI>();
|
|
65
|
+ private final List<URI> addresses = new ArrayList<>();
|
64
|
66
|
|
65
|
67
|
/** Whether to disable error reporting or not. */
|
66
|
68
|
private boolean disablereporting;
|
|
@@ -68,19 +70,18 @@ public class CommandLineParser {
|
68
|
70
|
/** The version string passed for the launcher. */
|
69
|
71
|
private String launcherVersion = "";
|
70
|
72
|
|
|
73
|
+ /** The configuration directory. */
|
|
74
|
+ private String configDirectory;
|
|
75
|
+
|
71
|
76
|
/** The RMI server we're using. */
|
72
|
77
|
private RemoteInterface server;
|
73
|
78
|
|
74
|
|
- /** Our parent Main. */
|
75
|
|
- private Main main;
|
76
|
|
-
|
77
|
79
|
/**
|
78
|
80
|
* Creates a new instance of CommandLineParser.
|
79
|
81
|
*
|
80
|
82
|
* @param arguments The arguments to be parsed
|
81
|
83
|
*/
|
82
|
|
- public CommandLineParser(final Main main, final String ... arguments) {
|
83
|
|
- this.main = main;
|
|
84
|
+ public CommandLineParser(final String ... arguments) {
|
84
|
85
|
boolean inArg = false;
|
85
|
86
|
char previousArg = '.';
|
86
|
87
|
|
|
@@ -115,7 +116,7 @@ public class CommandLineParser {
|
115
|
116
|
}
|
116
|
117
|
}
|
117
|
118
|
|
118
|
|
- new RemoteServer(main).bind();
|
|
119
|
+ new RemoteServer(Main.mainInstance).bind();
|
119
|
120
|
}
|
120
|
121
|
|
121
|
122
|
/**
|
|
@@ -252,11 +253,8 @@ public class CommandLineParser {
|
252
|
253
|
* @param address The address the user told us to connect to
|
253
|
254
|
*/
|
254
|
255
|
private void doConnect(final String address) {
|
255
|
|
- URI myAddress = null;
|
256
|
|
-
|
257
|
256
|
try {
|
258
|
|
- myAddress = NewServer.getURI(address);
|
259
|
|
- addresses.add(myAddress);
|
|
257
|
+ addresses.add(NewServer.getURI(address));
|
260
|
258
|
} catch (URISyntaxException ex) {
|
261
|
259
|
doUnknownArg("Invalid address specified: " + ex.getMessage());
|
262
|
260
|
}
|
|
@@ -293,9 +291,9 @@ public class CommandLineParser {
|
293
|
291
|
*/
|
294
|
292
|
private void doDirectory(final String dir) {
|
295
|
293
|
if (dir.endsWith(File.separator)) {
|
296
|
|
- main.setConfigDir(dir);
|
|
294
|
+ configDirectory = dir;
|
297
|
295
|
} else {
|
298
|
|
- main.setConfigDir(dir + File.separator);
|
|
296
|
+ configDirectory = dir + File.separator;
|
299
|
297
|
}
|
300
|
298
|
}
|
301
|
299
|
|
|
@@ -349,12 +347,22 @@ public class CommandLineParser {
|
349
|
347
|
exit();
|
350
|
348
|
}
|
351
|
349
|
|
|
350
|
+ /**
|
|
351
|
+ * Returns the user-supplied configuration directory.
|
|
352
|
+ *
|
|
353
|
+ * @return The user-supplied config directory, or {@code null} if none
|
|
354
|
+ * was supplied.
|
|
355
|
+ */
|
|
356
|
+ public String getConfigDirectory() {
|
|
357
|
+ return configDirectory;
|
|
358
|
+ }
|
|
359
|
+
|
352
|
360
|
/**
|
353
|
361
|
* Applies any applicable settings to the config identity.
|
354
|
362
|
*/
|
355
|
|
- public void applySettings() {
|
|
363
|
+ public void applySettings(final Identity globalIdentity) {
|
356
|
364
|
if (disablereporting) {
|
357
|
|
- IdentityManager.getIdentityManager().getGlobalConfigIdentity().setOption("temp", "noerrorreporting", true);
|
|
365
|
+ globalIdentity.setOption("temp", "noerrorreporting", true);
|
358
|
366
|
}
|
359
|
367
|
|
360
|
368
|
if (!launcherVersion.isEmpty()) {
|
|
@@ -365,10 +373,12 @@ public class CommandLineParser {
|
365
|
373
|
/**
|
366
|
374
|
* Processes arguments once the client has been loaded properly.
|
367
|
375
|
* This allows us to auto-connect to servers, etc.
|
|
376
|
+ *
|
|
377
|
+ * @param serverManager The server manager to use to connect servers.
|
368
|
378
|
*/
|
369
|
|
- public void processArguments() {
|
|
379
|
+ public void processArguments(final ServerManager serverManager) {
|
370
|
380
|
for (URI address : addresses) {
|
371
|
|
- main.getServerManager().connectToAddress(address);
|
|
381
|
+ serverManager.connectToAddress(address);
|
372
|
382
|
}
|
373
|
383
|
}
|
374
|
384
|
|