use of com.fathomdb.cli.commands.Ansi in project platformlayer by platformlayer.
the class ListItems 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, false);
}
ansi.reset();
}
use of com.fathomdb.cli.commands.Ansi in project platformlayer by platformlayer.
the class UntypedItemFormatter method formatItem.
public static void formatItem(UntypedItem o, Ansi ansi, boolean fullPath) {
UntypedItemXml item = (UntypedItemXml) o;
Ansi.Action action = null;
switch(item.getState()) {
case ACTIVE:
action = Ansi.TEXT_COLOR_GREEN;
break;
case BUILD_ERROR:
action = Ansi.TEXT_COLOR_RED;
break;
case DELETED:
action = Ansi.TEXT_COLOR_MAGENTA;
break;
default:
action = Ansi.TEXT_COLOR_BLUE;
break;
}
Ansi.Action undo = null;
if (action != null) {
undo = ansi.doAction(action);
}
try {
PlatformLayerKey plk = item.getKey();
if (fullPath) {
ansi.print(plk.getUrl());
} else {
ansi.print(plk.getItemId().getKey());
}
} finally {
if (undo != null) {
ansi.doAction(undo);
}
}
ansi.println();
}
Aggregations