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 outsincludeTargets << griffonScript("Init")
target(main: "The description of the script goes here!") {
println 'Hello world!'
debug 'Hello World (debug)'
}
setDefaultTarget(main)
Running the script without the flag will print out 'Hello World!' all the time but never the second one$ griffon hello
Welcome to Griffon 0.9.5-rc2 - http://griffon.codehaus.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 0.9.5-rc2 - http://griffon.codehaus.org/
Licensed under Apache Standard License 2.0
Griffon home is set to: /usr/local/griffon
…
Environment set to development
Hello world!
[11/11/10 4:43:04 PM] Hello World (debug)