public static String format(NodeDiff diff) { AnsiStoryBuilder resultBuilder = new AnsiStoryBuilder(); format(diff, resultBuilder); return resultBuilder.toString(); }
public static String format(Format format, Object o) { if (o == null) { return ""; } switch (format) { case YAML: return formatYaml(o); case JSON: return formatJson(o); case STRING: return o.toString(); case NONE: return ""; default: throw new RuntimeException("Unknown format: " + format); } }
private static String formatYaml(Object yaml) { if(List.class.isInstance(yaml)) { return getYamlParser().dump(getObjectMapper().convertValue(yaml, List.class)); } return getYamlParser().dump(getObjectMapper().convertValue(yaml, Map.class)); }
private static String formatJson(Object json) { try { return getObjectMapper().writeValueAsString(json); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
private static String formatJson(Object json) { try { return getObjectMapper().writeValueAsString(json); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
@Override protected void executeThis() { AnsiPrinter.out.println(AnsiFormatUtils.format(AnsiFormatUtils.Format.YAML, Daemon.getTasks())); } }
public static String format(Format format, Object o) { if (o == null) { return ""; } switch (format) { case YAML: return formatYaml(o); case JSON: return formatJson(o); case STRING: return o.toString(); case NONE: return ""; default: throw new RuntimeException("Unknown format: " + format); } }
private static String formatYaml(Object yaml) { if(yaml instanceof List) { return yamlParser.get().dump(getObjectMapper().convertValue(yaml, List.class)); } return yamlParser.get().dump(getObjectMapper().convertValue(yaml, Map.class)); }
@Override protected void executeThis() { AnsiPrinter.out.println(AnsiFormatUtils.format(AnsiFormatUtils.Format.YAML, Daemon.getTasks())); } }
public static String format(NodeDiff diff) { AnsiStoryBuilder resultBuilder = new AnsiStoryBuilder(); format(diff, resultBuilder); return resultBuilder.toString(); }
@Override protected void executeThis() { AnsiUi.success(AnsiFormatUtils.format(getAccount(getAccountName()))); }
@Override protected void executeThis() { AnsiUi.success(AnsiFormatUtils.format(getCluster(getClusterName()))); }
@Override protected void executeThis() { AnsiUi.success(AnsiFormatUtils.format(getAccount(getAccountName()))); }
@Override protected void executeThis() { AnsiUi.success(AnsiFormatUtils.format(getAccount(getAccountName()))); }
@Override protected void executeThis() { AnsiUi.success(AnsiFormatUtils.format(getCluster(getClusterName()))); }
@Override protected void executeThis() { AnsiUi.success(AnsiFormatUtils.format(getAccount(getAccountName()))); }
@Override public T get() { T res; try { res = operation.get(); } catch (ExpectedDaemonFailureException e) { throw new ExpectedDaemonFailureException(failureMesssage, e.getCause()); } catch (TaskKilledException e) { throw TaskKilledException.extendMessage(failureMesssage, e); } if (successMessage != null && !GlobalOptions.getGlobalOptions().isQuiet()) { AnsiUi.success(successMessage); } if (userFormatted) { Format userFormat = GlobalOptions.getGlobalOptions().getOutput(); if (userFormat != null) { format = userFormat; } } String result = AnsiFormatUtils.format(format, res); if (!result.isEmpty()) { AnsiPrinter.out.println(result); } return res; } }
@Override public T get() { T res; try { res = operation.get(); } catch (ExpectedDaemonFailureException e) { throw new ExpectedDaemonFailureException(failureMesssage, e.getCause()); } catch (TaskKilledException e) { throw TaskKilledException.extendMessage(failureMesssage, e); } if (successMessage != null && !GlobalOptions.getGlobalOptions().isQuiet()) { AnsiUi.success(successMessage); } if (userFormatted) { Format userFormat = GlobalOptions.getGlobalOptions().getOutput(); if (userFormat != null) { format = userFormat; } } String result = AnsiFormatUtils.format(format, res); if (!result.isEmpty()) { AnsiPrinter.out.println(result); } return res; } }
@Override protected void executeThis() { String deploymentName = getCurrentDeployment(); NodeDiff result = new OperationHandler<NodeDiff>() .setFailureMesssage("Failed to generate config diff.") .setOperation(Daemon.configDiff(deploymentName, !noValidate)) .get(); if (result == null) { AnsiUi.raw("No changes have been made to your configuration."); } else { AnsiUi.raw(AnsiFormatUtils.format(result)); } } }
@Override protected void executeThis() { String deploymentName = getCurrentDeployment(); NodeDiff result = new OperationHandler<NodeDiff>() .setFailureMesssage("Failed to generate config diff.") .setOperation(Daemon.configDiff(deploymentName, !noValidate)) .get(); if (result == null) { AnsiUi.raw("No changes have been made to your configuration."); } else { AnsiUi.raw(AnsiFormatUtils.format(result)); } } }