[PAN-2309] CLI mixin help (#895)

* don't create a new CommandLine object in the case of exception - this caused the help to be missing the mixins added

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Sally MacFarlane 6 years ago committed by GitHub
parent 4405571733
commit b1909f7ab6
  1. 4
      ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/TomlConfigFileParser.java
  2. 4
      pantheon/src/main/java/tech/pegasys/pantheon/cli/DefaultCommandValues.java
  3. 24
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java

@ -42,8 +42,8 @@ public class TomlConfigFileParser {
if (result.hasErrors()) {
final String errors =
result.errors().stream().map(TomlParseError::toString).collect(Collectors.joining("%n"));
throw new Exception("Invalid TOML configuration : " + errors);
result.errors().stream().map(TomlParseError::toString).collect(Collectors.joining("\n"));
throw new Exception("Invalid TOML configuration: \n" + errors);
}
return checkConfigurationValidity(result, toml);

@ -88,12 +88,12 @@ interface DefaultCommandValues {
}
// Try to create it, then verify if the provided path is not already existing and is not a
// directory .Otherwise, if it doesn't exist or exists but is already a directory,
// directory. Otherwise, if it doesn't exist or exists but is already a directory,
// Runner will use it to store data.
try {
Files.createDirectories(pantheonHome);
} catch (final FileAlreadyExistsException e) {
// Only thrown if it exist but is not a directory
// Only thrown if it exists but is not a directory
throw new CommandLine.ParameterException(
new CommandLine(command),
String.format(

@ -318,7 +318,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
private Long configureRefreshDelay(final Long refreshDelay) {
if (refreshDelay < DEFAULT_MIN_REFRESH_DELAY || refreshDelay > DEFAULT_MAX_REFRESH_DELAY) {
throw new ParameterException(
new CommandLine(this),
this.commandLine,
String.format(
"Refresh delay must be a positive integer between %s and %s",
String.valueOf(DEFAULT_MIN_REFRESH_DELAY),
@ -547,7 +547,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
//noinspection ConstantConditions
if (isMiningEnabled && coinbase == null) {
throw new ParameterException(
new CommandLine(this),
this.commandLine,
"Unable to mine without a valid coinbase. Either disable mining (remove --miner-enabled)"
+ "or specify the beneficiary of mining (via --miner-coinbase <Address>)");
}
@ -574,7 +574,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
metricsConfiguration(),
permissioningConfiguration);
} catch (Exception e) {
throw new ParameterException(new CommandLine(this), e.getMessage());
throw new ParameterException(this.commandLine, e.getMessage());
}
}
@ -590,7 +590,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
PermissioningConfigurationValidator.areAllBootnodesAreInWhitelist(
ethNetworkConfig, permissioningConfiguration);
} catch (final Exception e) {
throw new ParameterException(new CommandLine(this), e.getMessage());
throw new ParameterException(this.commandLine, e.getMessage());
}
}
@ -609,9 +609,9 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
.privacyParameters(privacyParameters())
.build();
} catch (final InvalidConfigurationException e) {
throw new ExecutionException(new CommandLine(this), e.getMessage());
throw new ExecutionException(this.commandLine, e.getMessage());
} catch (final IOException e) {
throw new ExecutionException(new CommandLine(this), "Invalid path", e);
throw new ExecutionException(this.commandLine, "Invalid path", e);
}
}
@ -694,7 +694,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
MetricsConfiguration metricsConfiguration() {
if (isMetricsEnabled && isMetricsPushEnabled) {
throw new ParameterException(
new CommandLine(this),
this.commandLine,
"--metrics-enabled option and --metrics-push-enabled option can't be used at the same "
+ "time. Please refer to CLI reference for more details about this constraint.");
}
@ -858,7 +858,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
// if user provided it and provided the genesis file option at the same time, it raises a
// conflict error
throw new ParameterException(
new CommandLine(this),
this.commandLine,
"--network option and --genesis-file option can't be used at the same time. Please "
+ "refer to CLI reference for more details about this constraint.");
}
@ -882,9 +882,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
.orElse(EthNetworkConfig.getNetworkConfig(MAINNET).getNetworkId()));
} catch (final DecodeException e) {
throw new ParameterException(
new CommandLine(this),
String.format("Unable to parse genesis file %s.", genesisFile),
e);
this.commandLine, String.format("Unable to parse genesis file %s.", genesisFile), e);
}
}
@ -913,9 +911,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
return Resources.toString(genesisFile().toURI().toURL(), UTF_8);
} catch (final IOException e) {
throw new ParameterException(
new CommandLine(this),
String.format("Unable to load genesis file %s.", genesisFile()),
e);
this.commandLine, String.format("Unable to load genesis file %s.", genesisFile()), e);
}
}

Loading…
Cancel
Save