mirror of
https://github.com/bisq-network/bisq.git
synced 2025-01-18 21:35:03 +01:00
Remove now unused BisqExecutable option handling
Option handling is now the responsibility of the Config class. JOpt's OptionParser is no longer passed down to BisqExecutable subclasses' doExecute method, as they can now rely on the Config abstraction.
This commit is contained in:
parent
7382344618
commit
3f605f873f
@ -168,7 +168,6 @@ public class Config {
|
||||
this.defaultConfigFile = new File(defaultAppDataDir, DEFAULT_CONFIG_FILE_NAME);
|
||||
|
||||
OptionParser parser = new OptionParser();
|
||||
parser.allowsUnrecognizedOptions();
|
||||
|
||||
AbstractOptionSpec<Void> helpOpt =
|
||||
parser.accepts("help", "Print this help text")
|
||||
|
@ -108,6 +108,13 @@ public class ConfigTests {
|
||||
assertThat(config.getAppName(), equalTo("Bisq-commandLineValue"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUnrecognizedOptionIsSet_thenThrowConfigException() {
|
||||
exceptionRule.expect(ConfigException.class);
|
||||
exceptionRule.expectMessage("problem parsing option 'bogus': bogus is not a recognized option");
|
||||
new TestConfig("--bogus");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenOptionFileArgumentDoesNotExist_thenThrowConfigException() {
|
||||
exceptionRule.expect(ConfigException.class);
|
||||
|
@ -41,10 +41,6 @@ import bisq.common.handlers.ResultHandler;
|
||||
import bisq.common.proto.persistable.PersistedDataHost;
|
||||
import bisq.common.setup.GracefulShutDownHandler;
|
||||
|
||||
import joptsimple.OptionException;
|
||||
import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
@ -61,7 +57,6 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet
|
||||
|
||||
private static final int EXIT_SUCCESS = 0;
|
||||
private static final int EXIT_FAILURE = 1;
|
||||
private static final String HELP_KEY = "help";
|
||||
|
||||
private final String fullName;
|
||||
private final String scriptName;
|
||||
@ -79,8 +74,7 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public void execute(String[] args) throws Exception {
|
||||
|
||||
public void execute(String[] args) {
|
||||
try {
|
||||
config = new Config(appName, args);
|
||||
} catch (HelpRequested helpRequested) {
|
||||
@ -98,35 +92,14 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet
|
||||
|
||||
initAppDir(config.getAppDataDir());
|
||||
|
||||
OptionParser parser = new OptionParser();
|
||||
parser.allowsUnrecognizedOptions();
|
||||
parser.formatHelpWith(new BisqHelpFormatter(fullName, scriptName, version));
|
||||
parser.accepts(HELP_KEY, "This help text").forHelp();
|
||||
|
||||
this.customizeOptionParsing(parser);
|
||||
|
||||
OptionSet options;
|
||||
try {
|
||||
options = parser.parse(args);
|
||||
if (options.has(HELP_KEY)) {
|
||||
parser.printHelpOn(System.out);
|
||||
System.exit(EXIT_SUCCESS);
|
||||
return;
|
||||
}
|
||||
} catch (OptionException ex) {
|
||||
System.err.println("error: " + ex.getMessage());
|
||||
System.exit(EXIT_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
this.doExecute(options);
|
||||
doExecute();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// First synchronous execution tasks
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
protected void doExecute(OptionSet options) {
|
||||
protected void doExecute() {
|
||||
configUserThread();
|
||||
CoreSetup.setup(config);
|
||||
addCapabilities();
|
||||
@ -257,16 +230,6 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// customizeOptionParsing
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
protected void customizeOptionParsing(OptionParser parser) {
|
||||
|
||||
//RpcOptionKeys
|
||||
}
|
||||
|
||||
private void initAppDir(File appDataDir) {
|
||||
Path dir = appDataDir.toPath();
|
||||
if (Files.exists(dir)) {
|
||||
|
@ -50,8 +50,8 @@ public class BisqHeadlessAppMain extends BisqExecutable {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(OptionSet options) {
|
||||
super.doExecute(options);
|
||||
protected void doExecute() {
|
||||
super.doExecute();
|
||||
|
||||
keepRunning();
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ public class SeedNodeMain extends ExecutableForAppWithP2p {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(OptionSet options) {
|
||||
super.doExecute(options);
|
||||
protected void doExecute() {
|
||||
super.doExecute();
|
||||
|
||||
checkMemory(config, this);
|
||||
startShutDownInterval(this);
|
||||
|
@ -37,14 +37,14 @@ public class StatisticsMain extends ExecutableForAppWithP2p {
|
||||
super("Bisq Statsnode", "bisq-statistics", "bisq_statistics", VERSION);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
public static void main(String[] args) {
|
||||
log.info("Statistics.VERSION: " + VERSION);
|
||||
new StatisticsMain().execute(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(OptionSet options) {
|
||||
super.doExecute(options);
|
||||
protected void doExecute() {
|
||||
super.doExecute();
|
||||
|
||||
checkMemory(config, this);
|
||||
CommonSetup.setup(this);
|
||||
|
Loading…
Reference in New Issue
Block a user