Refine search
@Override public boolean canAppearNext(CommandContext ctx) throws CommandFormatException { return !helpArg.isPresent(ctx.getParsedCommandLine()); } };
@Override public boolean canAppearNext(CommandContext ctx) { try { if(helpArg.isPresent(ctx.getParsedCommandLine())) { return false; } } catch (CommandFormatException e) { return false; } return true; } };
@Override public boolean canAppearNext(CommandContext ctx) throws CommandFormatException { return !helpArg.isPresent(ctx.getParsedCommandLine()); } };
@Override public boolean canAppearNext(CommandContext ctx) { try { if(helpArg.isPresent(ctx.getParsedCommandLine())) { return false; } } catch (CommandFormatException e) { return false; } return true; } };
@Override public boolean isBatchMode(CommandContext ctx) { try { if(this.helpArg.isPresent(ctx.getParsedCommandLine())) { return false; } } catch (CommandFormatException e) { // this is not nice... // but if it failed here it won't be added to the batch, // will be executed immediately and will fail with the same exception return false; } return true; } }
@Override public boolean isBatchMode(CommandContext ctx) { try { if(this.helpArg.isPresent(ctx.getParsedCommandLine())) { return false; } } catch (CommandFormatException e) { // this is not nice... // but if it failed here it won't be added to the batch, // will be executed immediately and will fail with the same exception return false; } return true; } }
@Override protected void doHandle(CommandContext ctx) throws CommandLineException { if (errorsArg.isPresent(ctx.getParsedCommandLine()) && !errors.isEmpty()) { final StringBuilder buf = new StringBuilder(); buf.append("The following problems were encountered while looking for additional commands in extensions:\n"); for (int i = 0; i < errors.size(); ++i) { final String error = errors.get(i); buf.append(i + 1).append(") ").append(error).append(Util.LINE_SEPARATOR); } ctx.printLine(buf.toString()); } } }
@Override protected void doHandle(CommandContext ctx) throws CommandLineException { if (errorsArg.isPresent(ctx.getParsedCommandLine()) && !errors.isEmpty()) { final StringBuilder buf = new StringBuilder(); buf.append("The following problems were encountered while looking for additional commands in extensions:\n"); for (int i = 0; i < errors.size(); ++i) { final String error = errors.get(i); buf.append(i + 1).append(") ").append(error).append(Util.LINE_SEPARATOR); } ctx.printLine(buf.toString()); } } }
protected void addAddRedeployLinksSteps(CommandContext ctx, ModelNode steps, String overlay, String serverGroup, String[] links, boolean regexp) throws CommandLineException { boolean warn = false; for(String link : links) { final ModelNode op = new ModelNode(); final ModelNode address = op.get(Util.ADDRESS); if(serverGroup != null) { address.add(Util.SERVER_GROUP, serverGroup); } address.add(Util.DEPLOYMENT_OVERLAY, overlay); address.add(Util.DEPLOYMENT, link); op.get(Util.OPERATION).set(Util.ADD); steps.add(op); if (redeployAffected.isPresent(ctx.getParsedCommandLine())) { addRedeployStep(overlay, link, serverGroup, steps); } else { warn = true; } } if (warn) { String warningMsg = serverGroup == null ? WARN_MSG + Arrays.toString(links) : WARN_MSG + Arrays.toString(links) + " in server group " + serverGroup; ctx.printLine(warningMsg); } }
@Override public HandledRequest buildHandledRequest(CommandContext ctx, Attachments attachments) throws CommandFormatException { String targetPath = targetFile.getValue(ctx.getParsedCommandLine()); String act = action.getValue(ctx.getParsedCommandLine()); if (act == null || act.isEmpty()) { throw new CommandFormatException("Action is missing"); } AttachmentResponseHandler handler = new AttachmentResponseHandler(ctx, targetPath, act.equals(SAVE), overwrite.isPresent(ctx.getParsedCommandLine()), createDirs.isPresent(ctx.getParsedCommandLine())); return new HandledRequest(buildRequest(ctx, attachments), handler); } }
@Override public HandledRequest buildHandledRequest(CommandContext ctx, Attachments attachments) throws CommandFormatException { String targetPath = targetFile.getValue(ctx.getParsedCommandLine()); String act = action.getValue(ctx.getParsedCommandLine()); if (act == null || act.isEmpty()) { throw new CommandFormatException("Action is missing"); } AttachmentResponseHandler handler = new AttachmentResponseHandler(ctx, targetPath, act.equals(SAVE), overwrite.isPresent(ctx.getParsedCommandLine()), createDirs.isPresent(ctx.getParsedCommandLine())); return new HandledRequest(buildRequest(ctx, attachments), handler); } }
@Override protected void handleResponse(CommandContext ctx, OperationResponse response, boolean composite) throws CommandLineException { ModelNode result = response.getResponseNode(); String targetPath = targetFile.getValue(ctx.getParsedCommandLine()); String act = action.getValue(ctx.getParsedCommandLine()); if (act == null || act.isEmpty()) { throw new CommandFormatException("Action is missing"); } AttachmentResponseHandler handler = new AttachmentResponseHandler(ctx, targetPath, act.equals(SAVE), overwrite.isPresent(ctx.getParsedCommandLine()), createDirs.isPresent(ctx.getParsedCommandLine())); handler.handleResponse(result, response); }
@Override protected void handleResponse(CommandContext ctx, OperationResponse response, boolean composite) throws CommandLineException { ModelNode result = response.getResponseNode(); String targetPath = targetFile.getValue(ctx.getParsedCommandLine()); String act = action.getValue(ctx.getParsedCommandLine()); if (act == null || act.isEmpty()) { throw new CommandFormatException("Action is missing"); } AttachmentResponseHandler handler = new AttachmentResponseHandler(ctx, targetPath, act.equals(SAVE), overwrite.isPresent(ctx.getParsedCommandLine()), createDirs.isPresent(ctx.getParsedCommandLine())); handler.handleResponse(result, response); }
@Override protected void recognizeArguments(CommandContext ctx) throws CommandFormatException { final ParsedCommandLine args = ctx.getParsedCommandLine(); final Set<String> propertyNames = args.getPropertyNames(); if(!propertyNames.isEmpty()) { final Collection<String> names; if(helpArg.isPresent(args)) { if(propertyNames.size() == 1) { return; } names = new ArrayList<String>(propertyNames); names.remove(helpArg.getFullName()); names.remove(helpArg.getShortName()); } else { names = propertyNames; } throw new CommandFormatException("Unrecognized argument names: " + names); } } }
@Override protected void doHandle(CommandContext ctx) throws CommandLineException { final ForControlFlow forCF = ForControlFlow.get(ctx); if (forCF == null) { throw new CommandLineException("done is not available outside 'for' loop"); } forCF.run(ctx, discard.isPresent(ctx.getParsedCommandLine())); } }
@Override protected void recognizeArguments(CommandContext ctx) throws CommandFormatException { final ParsedCommandLine args = ctx.getParsedCommandLine(); final Set<String> propertyNames = args.getPropertyNames(); if(!propertyNames.isEmpty()) { final Collection<String> names; if(helpArg.isPresent(args)) { if(propertyNames.size() == 1) { return; } names = new ArrayList<String>(propertyNames); names.remove(helpArg.getFullName()); names.remove(helpArg.getShortName()); } else { names = propertyNames; } throw new CommandFormatException("Unrecognized argument names: " + names); } } }
@Override protected void doHandle(CommandContext ctx) throws CommandLineException { final ForControlFlow forCF = ForControlFlow.get(ctx); if (forCF == null) { throw new CommandLineException("done is not available outside 'for' loop"); } forCF.run(ctx, discard.isPresent(ctx.getParsedCommandLine())); } }
@Override protected void recognizeArguments(CommandContext ctx) throws CommandFormatException { final ParsedCommandLine args = ctx.getParsedCommandLine(); final Set<String> propertyNames = args.getPropertyNames(); if(!propertyNames.isEmpty()) { final Collection<String> names; if(helpArg.isPresent(args)) { if(propertyNames.size() == 1) { return; } names = new ArrayList<String>(propertyNames); names.remove(helpArg.getFullName()); names.remove(helpArg.getShortName()); } else { names = propertyNames; } throw new CommandFormatException("Unrecognized argument names: " + names); } } }
@Override protected void recognizeArguments(CommandContext ctx) throws CommandFormatException { final ParsedCommandLine args = ctx.getParsedCommandLine(); final Set<String> propertyNames = args.getPropertyNames(); if(!propertyNames.isEmpty()) { final Collection<String> names; if(helpArg.isPresent(args)) { if(propertyNames.size() == 1) { return; } names = new ArrayList<String>(propertyNames); names.remove(helpArg.getFullName()); names.remove(helpArg.getShortName()); } else { names = propertyNames; } throw new CommandFormatException("Unrecognized argument names: " + names); } } }
@Override protected void recognizeArguments(CommandContext ctx) throws CommandFormatException { final ParsedCommandLine args = ctx.getParsedCommandLine(); final Set<String> propertyNames = args.getPropertyNames(); if(!propertyNames.isEmpty()) { final Collection<String> names; if(helpArg.isPresent(args)) { if(propertyNames.size() == 1) { return; } names = new ArrayList<String>(propertyNames); names.remove(helpArg.getFullName()); names.remove(helpArg.getShortName()); } else { names = propertyNames; } throw new CommandFormatException("Unrecognized argument names: " + names); } } }