[CORDA-1598] Make argument parsing more consistent. (#3423)

We parse command line arguments twice, once in `CordaCaplet.java`
  to determine the config file and base directory, and then again
  in NodeArgsParser. NodeArgsParser accepts long options with a
  single hyphen, while CordaCaplet did not. This changes
  CordaCaplet to accept `--config-file` as well as `-config-file`,
  same for base-dir.
This commit is contained in:
Florian Friemel 2018-06-26 14:32:45 +01:00 committed by GitHub
parent b4d31b1c77
commit 79626e9c4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,8 +20,16 @@ public class CordaCaplet extends Capsule {
private Config parseConfigFile(List<String> args) {
String baseDirOption = getOption(args, "--base-directory");
// Ensure consistent behaviour with NodeArgsParser.kt, see CORDA-1598.
if (null == baseDirOption || baseDirOption.isEmpty()) {
baseDirOption = getOption(args, "-base-directory");
}
this.baseDir = Paths.get((baseDirOption == null) ? "." : baseDirOption).toAbsolutePath().normalize().toString();
String config = getOption(args, "--config-file");
// Same as for baseDirOption.
if (null == config || config.isEmpty()) {
config = getOption(args, "-config-file");
}
File configFile = (config == null) ? new File(baseDir, "node.conf") : new File(config);
try {
ConfigParseOptions parseOptions = ConfigParseOptions.defaults().setAllowMissing(false);