@Override
    protected void doHandle(CommandContext ctx) throws CommandFormatException {

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

        Batch batch = batchManager.getActiveBatch();
        final int batchSize = batch.size();
        if(batchSize == 0) {
            throw new CommandFormatException("The batch is empty.");
        }

        List<String> arguments = ctx.getParsedCommandLine().getOtherProperties();
        if(arguments.isEmpty()) {
            throw new CommandFormatException("Missing line number.");
        }

        if(arguments.size() != 1) {
            throw new CommandFormatException("Expected only one argument - the line number but received: " + arguments);
        }

        String intStr = arguments.get(0);
        int lineNumber;
        try {
            lineNumber = Integer.parseInt(intStr);
        } catch(NumberFormatException e) {
            throw new CommandFormatException("Failed to parse line number '" + intStr + "': " + e.getLocalizedMessage());
        }

        if(lineNumber < 1 || lineNumber > batchSize) {
            throw new CommandFormatException(lineNumber + " isn't in range [1.." + batchSize + "].");
        }

        batch.remove(lineNumber - 1);
    }
@ Override protected void doHandle ( CommandContext ctx ) throws CommandFormatException { BatchManager batchManager = ctx . getBatchManager ( ) ; if ( ! batchManager . isBatchActive ( ) ) { throw new CommandFormatException ( "No active batch." ) ; } Batch batch = batchManager . getActiveBatch ( ) ; final int batchSize = batch . size ( ) ; if ( batchSize == 0 ) { throw new CommandFormatException ( "The batch is empty." ) ; } List < String > arguments = ctx . getParsedCommandLine ( ) . getOtherProperties ( ) ; if ( arguments . isEmpty ( ) ) { throw new CommandFormatException ( "Missing line number." ) ; } if ( arguments . size ( ) != 1 ) { throw new CommandFormatException ( "Expected only one argument - the line number but received: " + arguments ) ; } String intStr = arguments . get ( 0 ) ; int lineNumber ; try { lineNumber = Integer . parseInt ( intStr ) ; } catch ( NumberFormatException e ) { throw new CommandFormatException ( "Failed to parse line number '" + intStr + "': " + e . getLocalizedMessage ( ) ) ; } if ( lineNumber < 1 || lineNumber > batchSize ) { throw new CommandFormatException ( lineNumber + " isn't in range [1.." + batchSize + "]." ) ; } batch . remove ( lineNumber - 1 ) ; }
/* (non-Javadoc)
@see org.jboss.as.cli.handlers.CommandHandlerWithHelp#doHandle(org.jboss.as.cli.CommandContext)