use of com.fathomdb.cli.commands.Ansi in project platformlayer by platformlayer.
the class ListJobs method formatRaw.
@Override
public void formatRaw(Object o, PrintWriter writer) {
JobDataList jobs = (JobDataList) o;
switch(getFormat()) {
case JSON:
JsonHelper<JobDataList> jsonHelper = JsonHelper.build(JobDataList.class);
boolean formatted = true;
try {
String json = jsonHelper.marshal(jobs, formatted);
writer.println(json);
return;
} catch (IOException e) {
throw new CliException("Error formatting for output", e);
}
}
Ansi ansi = new Ansi(writer);
for (JobData job : jobs.getJobs()) {
// JobState state = job.state;
// if (state != null) {
// ansi.setColorBlue();
// switch (job.state) {
// case FAILED:
// ansi.setColorRed();
// break;
//
// case SUCCESS:
// ansi.setColorGreen();
// break;
//
// case RUNNING:
// ansi.setColorBlue();
// break;
//
// default:
// ansi.setColorBlue();
// break;
// }
// }
writer.println(job.key);
}
ansi.reset();
}
use of com.fathomdb.cli.commands.Ansi in project platformlayer by platformlayer.
the class ListRoots method formatRaw.
@Override
public void formatRaw(Object o, PrintWriter writer) {
Ansi ansi = new Ansi(writer);
Iterable<UntypedItem> items = (Iterable<UntypedItem>) o;
for (UntypedItem item : items) {
UntypedItemFormatter.formatItem(item, ansi, true);
}
ansi.reset();
}
use of com.fathomdb.cli.commands.Ansi in project platformlayer by platformlayer.
the class PlatformLayerCommandRunnerBase method formatRaw.
@Override
public void formatRaw(Object o, PrintWriter writer) {
String data;
if (o instanceof UntypedItemXml) {
UntypedItemXml item = (UntypedItemXml) o;
Source src = new DOMSource(item.getRoot());
String xml = DomUtils.toXml(src, 4);
data = xml;
} else if (o instanceof UntypedItemJson) {
UntypedItemJson item = (UntypedItemJson) o;
JSONObject root = item.getRoot();
try {
data = root.toString(2);
} catch (JSONException e) {
throw new IllegalStateException("Error formatting JSON", e);
}
} else {
super.formatRaw(o, writer);
return;
}
Ansi ansi = new Ansi(writer);
ansi.print(data);
ansi.println();
ansi.reset();
}
use of com.fathomdb.cli.commands.Ansi in project platformlayer by platformlayer.
the class ListChildren method formatRaw.
@Override
public void formatRaw(Object o, PrintWriter writer) {
Ansi ansi = new Ansi(writer);
Iterable<UntypedItem> items = (Iterable<UntypedItem>) o;
for (UntypedItem item : items) {
UntypedItemFormatter.formatItem(item, ansi, true);
}
ansi.reset();
}
use of com.fathomdb.cli.commands.Ansi in project platformlayer by platformlayer.
the class ListJobExecutions method formatRaw.
@Override
public void formatRaw(Object o, PrintWriter writer) {
JobExecutionList jobs = (JobExecutionList) o;
switch(getFormat()) {
case JSON:
JsonHelper<JobExecutionList> jsonHelper = JsonHelper.build(JobExecutionList.class);
boolean formatted = true;
try {
String json = jsonHelper.marshal(jobs, formatted);
writer.println(json);
return;
} catch (IOException e) {
throw new CliException("Error formatting for output", e);
}
}
Ansi ansi = new Ansi(writer);
for (JobExecutionData job : jobs) {
JobState state = job.state;
if (state != null) {
switch(job.state) {
case FAILED:
ansi.setColorRed();
break;
case SUCCESS:
ansi.setColorGreen();
break;
case RUNNING:
ansi.setColorBlue();
break;
default:
ansi.setColorBlue();
break;
}
} else {
ansi.setColorBlue();
}
writer.println(job.getJobId() + "/" + job.executionId);
}
ansi.reset();
}
Aggregations