(Quick Reference)

4.7.2 Verbose Output - Reference Documentation

Authors: Andres Almiray

Version: 1.2.0

4.7.2 Verbose Output

Scripts have the choice of printing to the console whenever they need to communicate something to the developer. They would normally use a standard println sentence. Sometimes it's useful to know what a script is doing with further detail but it makes no sense to see that information every single time. A conditional output is required.

All scripts inherit a debug() closure that will print its argument to stdout if an only if the following flag is enabled: griffon.cli.verbose. As an example, the following script has two print outs

// Include core griffon scripts with the following call
//
//     includeTargets << griffonScript('_GriffonCompile')
//
// Include plugin scripts with the following call
//
//    includeTargets << griffonPluginScript('some-plugin-name', 'ScriptName')
//

target(name: 'hello', description: "The description of the script goes here!", prehook: null, posthook: null) { println 'Hello world!' debug 'Hello World (debug)' } setDefaultTarget('hello')

Running the script without the flag will print out 'Hello World!' all the time but never the second one

$ griffon hello
Welcome to Griffon 1.2.0 - http://griffon-framework.org/
Licensed under Apache Standard License 2.0
Griffon home is set to: /usr/local/griffon
…
Environment set to development
Hello world!

The second message will only appear if you specify the verbose flag

$ griffon -Dgriffon.cli.verbose=true hello
Welcome to Griffon 1.2.0 - http://griffon-framework.org/
Licensed under Apache Standard License 2.0
Griffon home is set to: /usr/local/griffon
…
Environment set to development
Hello world!
[5/15/12 11:39:12 AM] Hello World (debug)