package org.rundeck.client.util;

import com.simplifyops.toolbelt.ANSIColorOutput;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Created by greg on 7/19/16.
 */
public class Colorz {
    /**
     * Return a map with key/values replaced with colorized versions, if specified
     *
     * @param data data
     * @param key  key color, or null
     *
     * @return colorized keys/values
     */
    public static Map<?, ?> colorizeMapRecurse(
            Map<?, ?> data,
            ANSIColorOutput.Color key
    )
    {
        LinkedHashMap<Object, Object> result = new LinkedHashMap<>();
        data.keySet().forEach(k -> {
            final Object value = data.get(k);
            result.put(
                    key != null ? ANSIColorOutput.colorize(key, k.toString()) : k,
                    value instanceof Map ? colorizeMapRecurse((Map) value, key) : value
            );
        });
        return result;
    }
}

@@ -77,16 +77,41 @@
 utput;%0A%0A
+import java.util.Arrays;%0A
 import j
@@ -354,19 +354,22 @@
  @param 
-key
+colors
   key co
@@ -542,20 +542,26 @@
 ut.Color
- key
+... colors
 %0A    )%0A 
@@ -734,103 +734,607 @@
     
-result.put(%0A                    key != null ? ANSIColorOutput.colorize(key, k.toString())
+ANSIColorOutput.Color keyColor = colors != null && colors.length %3E 0 ? colors%5B0%5D : null;%0A            ANSIColorOutput.Color%5B%5D subcolors = null;%0A            if (colors != null && colors.length %3E 1) %7B%0A                subcolors = new ANSIColorOutput.Color%5Bcolors.length - 1%5D;%0A                System.arraycopy(colors, 1, subcolors, 0, subcolors.length);%0A            %7D%0A            result.put(%0A                    keyColor != null%0A                    ? ANSIColorOutput.colorize(%0A                            keyColor,%0A                            k.toString()%0A                    )%0A                   
  : k,%0A
+%0A
     
@@ -1374,46 +1374,192 @@
 Map 
-? colorizeMapRecurse((Map) value, key)
+&& subcolors != null%0A                    ? colorizeMapRecurse(%0A                            (Map) value,%0A                            subcolors%0A                    )%0A%0A                   
  : v

Update to support more than one color