public static String format(final String code, final Object... args) {
        if (args.length == 0) {
            return code + '\r';
        }

        StringBuilder builder = new StringBuilder(code);

        int num = args.length;
        for (int i = 0; i < num - 1; i++) {
            builder.append(' ').append(args[i]);
        }

        String last = args[num - 1].toString().replaceAll("\\s+", " ");

        if (last.length() == 0 || (last.indexOf(' ') == -1 && last.charAt(0) != ':')) {
            return builder.append(' ').append(last).append('\r').toString();
        } else {
            return builder.append(" :").append(last).append('\r').toString();
        }
    }