Search in sources :

Example 1 with CLIException

use of io.vertx.core.cli.CLIException in project vert.x by eclipse.

the class RunCommand method setUp.

/**
   * Validates the command line parameters.
   *
   * @param context - the execution context
   * @throws CLIException - validation failed
   */
@Override
public void setUp(ExecutionContext context) throws CLIException {
    super.setUp(context);
    // If cluster-host and / or port is set, cluster need to have been explicitly set
    io.vertx.core.cli.Option clusterHostOption = executionContext.cli().getOption("cluster-host");
    io.vertx.core.cli.Option clusterPortOption = executionContext.cli().getOption("cluster-port");
    CommandLine commandLine = executionContext.commandLine();
    if ((!isClustered()) && (commandLine.isOptionAssigned(clusterHostOption) || commandLine.isOptionAssigned(clusterPortOption))) {
        throw new CLIException("The option -cluster-host and -cluster-port requires -cluster to be enabled");
    }
    // If quorum and / or ha-group, ha need to have been explicitly set
    io.vertx.core.cli.Option haGroupOption = executionContext.cli().getOption("hagroup");
    io.vertx.core.cli.Option quorumOption = executionContext.cli().getOption("quorum");
    if (!ha && (commandLine.isOptionAssigned(haGroupOption) || commandLine.isOptionAssigned(quorumOption))) {
        throw new CLIException("The option -hagroup and -quorum requires -ha to be enabled");
    }
}
Also used : CommandLine(io.vertx.core.cli.CommandLine) CLIException(io.vertx.core.cli.CLIException)

Aggregations

CLIException (io.vertx.core.cli.CLIException)1 CommandLine (io.vertx.core.cli.CommandLine)1