/** * Prints a string to the CLI's output. * * @param message the message to print */ default void print(String message) { printLine(message); }
private void printLine(CommandContext ctx, final Collection<String> deployment, final String sgName) { String message = WARN_MSG + deployment; if (sgName == null) { ctx.printLine(message); } else { // domain mode with server group specified. ctx.printLine(message + " in server group " + sgName); } }
private void printLine(CommandContext ctx, final Collection<String> deployment, final String sgName) { String message = WARN_MSG + deployment; if (sgName == null) { ctx.printLine(message); } else { // domain mode with server group specified. ctx.printLine(message + " in server group " + sgName); } }
@Override public void printLine(String message) { wrapped.printLine(message); }
protected void printSupportedCommands(CommandContext ctx) throws CommandLineException { final List<String> list = getSupportedCommands(ctx); list.add("To read the description of a specific command execute '" + this.commandName + " command_name --help'."); for(String name : list) { ctx.printLine(name); } }
private static void printList(CommandContext ctx, Collection<String> list, boolean l) { if (l) { for (String item : list) { ctx.printLine(item); } } else { ctx.printColumns(list); } }
private static void printList(CommandContext ctx, Collection<String> list, boolean l) { if (l) { for (String item : list) { ctx.printLine(item); } } else { ctx.printColumns(list); } }
@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()); } } }
private void saveContent(CommandContext ctx, OperationResponse operationResponse, String uuid, Path filepath) throws IOException { OperationResponse.StreamEntry stream = operationResponse.getInputStream(uuid); if (stream.getMimeType() != null && stream.getMimeType().contains(format)) { try (InputStream in = stream.getStream()) { Files.copy(in, filepath, StandardCopyOption.REPLACE_EXISTING); ctx.printLine("Report saved in " + filepath); } } }
private void saveContent(CommandContext ctx, OperationResponse operationResponse, String uuid, Path filepath) throws IOException { OperationResponse.StreamEntry stream = operationResponse.getInputStream(uuid); if (stream.getMimeType() != null && stream.getMimeType().contains(format)) { try (InputStream in = stream.getStream()) { Files.copy(in, filepath, StandardCopyOption.REPLACE_EXISTING); ctx.printLine("Report saved in " + filepath); } } }
protected void displayResponseHeaders(CommandContext ctx, ModelNode response) { if(response.has(Util.RESPONSE_HEADERS)) { final ModelNode headers = response.get(Util.RESPONSE_HEADERS); final Set<String> keys = headers.keys(); final SimpleTable table = new SimpleTable(2, ctx.getTerminalWidth()); for (String key : keys) { table.addLine(new String[] { key + ':', headers.get(key).asString() }); } final StringBuilder buf = new StringBuilder(); table.append(buf, true); ctx.printLine(buf.toString()); } }
private void printLayerPatches(CommandContext ctx, final ModelNode result, final String type) { ModelNode layer = result.get(type); if (layer.isDefined()) { final String header = Character.toUpperCase(type.charAt(0)) + type.substring(1) + ':'; for (String name : layer.keys()) { final ModelNode node = layer.get(name); final SimpleTable table = new SimpleTable(2, ctx.getTerminalWidth()); table.addLine(new String[]{header, name}); addPatchesInfo(node, table); ctx.printLine(lineSeparator + table.toString(false)); } } }
@Override protected void handleResponse(CommandContext ctx, ModelNode opResponse, boolean composite) throws CommandFormatException { //System.out.println(opResponse); if (!Util.isSuccess(opResponse)) { throw new CommandFormatException(Util.getFailureDescription(opResponse)); } final StringBuilder buf = formatResponse(ctx, opResponse, composite, null); if(buf != null) { ctx.printLine(buf.toString()); } }
@Override protected void handleResponse(CommandContext ctx, ModelNode opResponse, boolean composite) throws CommandFormatException { //System.out.println(opResponse); if (!Util.isSuccess(opResponse)) { throw new CommandFormatException(Util.getFailureDescription(opResponse)); } final StringBuilder buf = formatResponse(ctx, opResponse, composite, null); if(buf != null) { ctx.printLine(buf.toString()); } }
@Override protected void doHandle(CommandContext ctx) { OperationRequestAddress prefix = ctx.getCurrentNodePath(); ctx.printLine(ctx.getNodePathFormatter().format(prefix)); } }
@Override public CommandResult execute(CLICommandInvocation commandInvocation) throws CommandException, InterruptedException { if (help) { commandInvocation.getCommandContext().printLine(commandInvocation.getHelpInfo("patch")); return CommandResult.SUCCESS; } throw new CommandException("Command action is missing."); } }
@Override public CommandResult execute(CLICommandInvocation commandInvocation) throws CommandException, InterruptedException { if (help) { commandInvocation.getCommandContext().printLine(commandInvocation.getHelpInfo("patch")); return CommandResult.SUCCESS; } throw new CommandException("Command action is missing."); } }
@Override public CommandResult execute(CLICommandInvocation commandInvocation) throws CommandException, InterruptedException { CommandContext ctx = commandInvocation.getCommandContext(); ModelNode request; try { request = buildRequest(ctx); } catch (CommandFormatException ex) { throw new CommandException(ex.getLocalizedMessage(), ex); } SecurityCommand.execute(ctx, request, SecurityCommand.DEFAULT_FAILURE_CONSUMER, noReload); ctx.printLine("SSL disabled for " + serverName); return CommandResult.SUCCESS; }