From 29abb9ee1d140ec92604fc20cf041673048c98df Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Thu, 9 Jan 2020 21:19:37 +0100 Subject: [PATCH] Reorder a few of the most important options There is currently no explicit rule for how option-related elements are ordered in the code, but it is important to understand that the order in which options are registered via parser.accept() calls is the order in which they appear in --help output. It would be nice to group options together into sections and separate them in the --help output with section headers similar to the way that Bitcoin Core's help output does it, but this is not a built-in option with the JOpt Simple library, and not worth trying to hack into place at the moment. --- .../main/java/bisq/common/config/Config.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/common/src/main/java/bisq/common/config/Config.java b/common/src/main/java/bisq/common/config/Config.java index 5bfa86e4630..4b0aa527130 100644 --- a/common/src/main/java/bisq/common/config/Config.java +++ b/common/src/main/java/bisq/common/config/Config.java @@ -48,10 +48,11 @@ public class Config { // Option name constants public static final String HELP = "help"; public static final String APP_NAME = "appName"; - public static final String APP_DATA_DIR = "appDataDir"; public static final String USER_DATA_DIR = "userDataDir"; + public static final String APP_DATA_DIR = "appDataDir"; public static final String CONFIG_FILE = "configFile"; public static final String MAX_MEMORY = "maxMemory"; + public static final String LOG_LEVEL = "logLevel"; public static final String BANNED_BTC_NODES = "bannedBtcNodes"; public static final String BANNED_PRICE_RELAY_NODES = "bannedPriceRelayNodes"; public static final String BANNED_SEED_NODES = "bannedSeedNodes"; @@ -66,7 +67,6 @@ public class Config { public static final String DUMP_STATISTICS = "dumpStatistics"; public static final String IGNORE_DEV_MSG = "ignoreDevMsg"; public static final String PROVIDERS = "providers"; - public static final String LOG_LEVEL = "logLevel"; public static final String SEED_NODES = "seedNodes"; public static final String BAN_LIST = "banList"; public static final String NODE_PORT = "nodePort"; @@ -134,6 +134,8 @@ public class Config { private final File userDataDir; private final File appDataDir; private final int nodePort; + private final int maxMemory; + private final String logLevel; private final List bannedBtcNodes; private final List bannedPriceRelayNodes; private final List bannedSeedNodes; @@ -142,12 +144,10 @@ public class Config { private final boolean ignoreLocalBtcNode; private final String bitcoinRegtestHost; private final boolean daoActivated; - private final String logLevel; private final String referralId; private final boolean useDevMode; private final boolean useDevPrivilegeKeys; private final boolean dumpStatistics; - private final int maxMemory; private final boolean ignoreDevMsg; private final List providers; private final List seedNodes; @@ -246,18 +246,18 @@ public Config(String defaultAppName, File defaultUserDataDir, String... args) { .ofType(String.class) .defaultsTo(DEFAULT_CONFIG_FILE_NAME); - ArgumentAcceptingOptionSpec userDataDirOpt = - parser.accepts(USER_DATA_DIR, "User data directory") - .withRequiredArg() - .ofType(File.class) - .defaultsTo(this.defaultUserDataDir); - ArgumentAcceptingOptionSpec appNameOpt = parser.accepts(APP_NAME, "Application name") .withRequiredArg() .ofType(String.class) .defaultsTo(this.defaultAppName); + ArgumentAcceptingOptionSpec userDataDirOpt = + parser.accepts(USER_DATA_DIR, "User data directory") + .withRequiredArg() + .ofType(File.class) + .defaultsTo(this.defaultUserDataDir); + ArgumentAcceptingOptionSpec appDataDirOpt = parser.accepts(APP_DATA_DIR, "Application data directory") .withRequiredArg() @@ -270,6 +270,19 @@ public Config(String defaultAppName, File defaultUserDataDir, String... args) { .ofType(Integer.class) .defaultsTo(9999); + ArgumentAcceptingOptionSpec maxMemoryOpt = + parser.accepts(MAX_MEMORY, "Max. permitted memory (used only by headless versions)") + .withRequiredArg() + .ofType(int.class) + .defaultsTo(1200); + + ArgumentAcceptingOptionSpec logLevelOpt = + parser.accepts(LOG_LEVEL, "Set logging level") + .withRequiredArg() + .ofType(String.class) + .describedAs("OFF|ALL|ERROR|WARN|INFO|DEBUG|TRACE") + .defaultsTo(Level.INFO.levelStr); + ArgumentAcceptingOptionSpec bannedBtcNodesOpt = parser.accepts(BANNED_BTC_NODES, "List Bitcoin nodes to ban") .withRequiredArg() @@ -313,13 +326,6 @@ public Config(String defaultAppName, File defaultUserDataDir, String... args) { .describedAs("host[:port]") .defaultsTo(""); - ArgumentAcceptingOptionSpec logLevelOpt = - parser.accepts(LOG_LEVEL, "Set logging level") - .withRequiredArg() - .ofType(String.class) - .describedAs("OFF|ALL|ERROR|WARN|INFO|DEBUG|TRACE") - .defaultsTo(Level.INFO.levelStr); - ArgumentAcceptingOptionSpec referralIdOpt = parser.accepts(REFERRAL_ID, "Optional Referral ID (e.g. for API users or pro market makers)") .withRequiredArg() @@ -346,12 +352,6 @@ public Config(String defaultAppName, File defaultUserDataDir, String... args) { .ofType(boolean.class) .defaultsTo(false); - ArgumentAcceptingOptionSpec maxMemoryOpt = - parser.accepts(MAX_MEMORY, "Max. permitted memory (used only by headless versions)") - .withRequiredArg() - .ofType(int.class) - .defaultsTo(1200); - ArgumentAcceptingOptionSpec ignoreDevMsgOpt = parser.accepts(IGNORE_DEV_MSG, "If set to true all signed " + "network_messages from bisq developers are ignored (Global " + @@ -639,6 +639,8 @@ public Config(String defaultAppName, File defaultUserDataDir, String... args) { this.helpRequested = options.has(helpOpt); this.configFile = configFile; this.nodePort = options.valueOf(nodePortOpt); + this.maxMemory = options.valueOf(maxMemoryOpt); + this.logLevel = options.valueOf(logLevelOpt); this.bannedBtcNodes = options.valuesOf(bannedBtcNodesOpt); this.bannedPriceRelayNodes = options.valuesOf(bannedPriceRelayNodesOpt); this.bannedSeedNodes = options.valuesOf(bannedSeedNodesOpt); @@ -646,7 +648,6 @@ public Config(String defaultAppName, File defaultUserDataDir, String... args) { this.baseCurrencyNetworkParameters = baseCurrencyNetwork.getParameters(); this.ignoreLocalBtcNode = options.valueOf(ignoreLocalBtcNodeOpt); this.bitcoinRegtestHost = options.valueOf(bitcoinRegtestHostOpt); - this.logLevel = options.valueOf(logLevelOpt); this.torrcFile = options.has(torrcFileOpt) ? options.valueOf(torrcFileOpt).toFile() : null; this.torrcOptions = options.valueOf(torrcOptionsOpt); this.torControlPort = options.valueOf(torControlPortOpt); @@ -659,7 +660,6 @@ public Config(String defaultAppName, File defaultUserDataDir, String... args) { this.useDevMode = options.valueOf(useDevModeOpt); this.useDevPrivilegeKeys = options.valueOf(useDevPrivilegeKeysOpt); this.dumpStatistics = options.valueOf(dumpStatisticsOpt); - this.maxMemory = options.valueOf(maxMemoryOpt); this.ignoreDevMsg = options.valueOf(ignoreDevMsgOpt); this.providers = options.valuesOf(providersOpt); this.seedNodes = options.valuesOf(seedNodesOpt);