Search in sources :

Example 6 with Ansi

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();
}
Also used : UntypedItem(org.platformlayer.common.UntypedItem) Ansi(com.fathomdb.cli.commands.Ansi)

Example 7 with Ansi

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();
}
Also used : UntypedItemXml(org.platformlayer.UntypedItemXml) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) Ansi(com.fathomdb.cli.commands.Ansi)

Aggregations

Ansi (com.fathomdb.cli.commands.Ansi)7 UntypedItem (org.platformlayer.common.UntypedItem)3 CliException (com.fathomdb.cli.CliException)2 IOException (java.io.IOException)2 UntypedItemXml (org.platformlayer.UntypedItemXml)2 Source (javax.xml.transform.Source)1 DOMSource (javax.xml.transform.dom.DOMSource)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1 UntypedItemJson (org.platformlayer.UntypedItemJson)1 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)1 JobData (org.platformlayer.jobs.model.JobData)1 JobDataList (org.platformlayer.jobs.model.JobDataList)1 JobExecutionData (org.platformlayer.jobs.model.JobExecutionData)1 JobExecutionList (org.platformlayer.jobs.model.JobExecutionList)1 JobState (org.platformlayer.jobs.model.JobState)1