Sign in to edit and +1 items.
Login required
Download

Grails console enhancements

(0)
Author(s) Antony Jones (Desirable Objects)
Current Release 0.5   (5 months ago)
Grails Version 1.3.1 > *
Tags ansi  color  colour  console  desirable-objects  development  linux  unix 
Dependency
compile ":console-enhancements:0.5"
Enhances the grails console output for better visibility
Last updated by antony 7 months ago
grails install-plugin console-enhancements
Last updated by antony 7 months ago
Enhances the grails console output for better visibility.

Rationale

This plugin was born as a result of seeing too many of my colleagues typing:

println ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ${myValue}"

Usage

Usage is designed to be as simple and as unintrusive as possible. Essentially this plugin takes the bold step of overriding the 'println' method on the Object class'. What this means is that any time you type:

println "my text"

Your println will come up in the console in bold, colour, flashing, or whatever custom values you have put into the configuration (see below)

If you want to use a custom set of colours for a particular println, you can use up to three:

println ANSICode.ITALIC_ON, ANSICode.FOREGROUND_RED, ANSICode.BACKGROUND_YELLOW, "my text"

If you want any more control, see 'advanced usage below'.

Configuration

Configuration is automatic, if you like your printlns in bold aqua coloured text. If not, it's simple to override:

console {
    colours {
        normal = [ANSICode.FOREGROUND_RED, ANSICode.BOLD_ON]
    }
}

Where the list assigned to the 'normal' attribute can by any number of values from the provided ANSICode enum. The ANSI escape sequence is automatically reset after each println.

Limitations

This plugin requires that you have an ANSI capable terminal. As with most things that are great about computing, this means that this plugin will not work on windows, and will likely print a number of ugly ANSI escape sequences around your printlns!

Advanced Usage

You can format any text using ANSI by manually invoking the ANSISequence class' .format method. This is probably most useful in Grails event scripts:

new ANSISequence(ANSICode.FOREGROUND_YELLOW, ANSICode.BACKGROUND_MAGENTA).format('test message')
Last updated by admin 8 months ago
Last updated by admin 8 months ago