cmdCtx.getOperationRequestParser().parse(line, builder);
ModelNode request = builder.buildRequest();
StringBuilder op = new StringBuilder();
op.append(cmdCtx.getPrefixFormatter().format(builder.getAddress()));
op.append(line.substring(line.indexOf(':')));
DefaultBatchedCommand batchedCmd = new DefaultBatchedCommand(op.toString(), request);
Batch batch = cmdCtx.getBatchManager().getActiveBatch();
batch.add(batchedCmd);
cmdCtx.printLine("#" + batch.size() + " " + batchedCmd.getCommand());
} catch (CommandFormatException e) {
cmdCtx.printLine(e.getLocalizedMessage());
}
} else {
cmdCtx.operationHandler.handle(cmdCtx);
}
} else {
String cmd = line;
String cmdArgs = null;
for (int i = 0; i < cmd.length(); ++i) {
if (Character.isWhitespace(cmd.charAt(i))) {
cmdArgs = cmd.substring(i + 1).trim();
cmd = cmd.substring(0, i);
break;
}
}
CommandHandler handler = cmdRegistry.getCommandHandler(cmd.toLowerCase());
if(handler != null) {
cmdCtx.setArgs(cmd, cmdArgs, handler);
if(cmdCtx.isBatchMode() && handler.isBatchMode()) {
if(!(handler instanceof OperationCommand)) {
cmdCtx.printLine("The command is not allowed in a batch.");
} else {
try {
ModelNode request = ((OperationCommand)handler).buildRequest(cmdCtx);
BatchedCommand batchedCmd = new DefaultBatchedCommand(line, request);
Batch batch = cmdCtx.getBatchManager().getActiveBatch();
batch.add(batchedCmd);
cmdCtx.printLine("#" + batch.size() + " " + batchedCmd.getCommand());
} catch (CommandFormatException e) {
cmdCtx.printLine("Failed to add to batch: " + e.getLocalizedMessage());
}
}
} else {