/* (non-Javadoc)
   * @see org.jboss.as.cli.handlers.CommandHandlerWithHelp#doHandle(org.jboss.as.cli.CommandContext)
   */
  @Override
  protected void doHandle(CommandContext ctx) throws CommandFormatException {

    BatchManager batchManager = ctx.getBatchManager();
    if (!batchManager.isBatchActive()) {
      throw new CommandFormatException("No active batch to holdback.");
    }

    String name = null;
    ParsedCommandLine args = ctx.getParsedCommandLine();
    if (args.hasProperties()) {
      name = args.getOtherProperties().get(0);
    }

    if (batchManager.isHeldback(name)) {
      throw new CommandFormatException(
          "There already is "
              + (name == null ? "unnamed" : "'" + name + "'")
              + " batch held back.");
    }

    if (!batchManager.holdbackActiveBatch(name)) {
      throw new CommandFormatException("Failed to holdback the batch.");
    }
  }