Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Grails Goodness: Script Name Abbreviation

DZone's Guide to

Grails Goodness: Script Name Abbreviation

· Java Zone ·
Free Resource

Verify, standardize, and correct the Big 4 + more– name, email, phone and global addresses – try our Data Quality APIs now at Melissa Developer Portal!

During Gr8Conf 2012 Europe I discovered Grails supports script name abbreviation. This means we don't have to type a complete script name, but only enough to make the script identifiable by Grails. It is inspired by Gradle's task name abbreviation feature. For example if we want to invoke the help script we only have to type the letter h. Or to invoke run-app we type rA. Notice we use uppercase characters for the letters after a hyphen in a script name. To invoke create-tag-lib we can type cTL.

If Grails cannot find a unique script name for the abbreviation we use we get a list of possible script names. We select the correct one to invoke the script. For example in the following output we see the options Grails shows when we type gen as a script name abbreviation:

$ grails gen
| Script 'Gen' not found, did you mean:
1) GenerateAll
2) GenerateViews
3) GenerateController
4) InstallDependency
5) DependencyReport
> Please make a selection or enter Q to quit: 

This feature also works for script that we create ourselves or are added by plugins. For example if we create a script GrailsGoodness with the following content:

includeTargets << grailsScript("_GrailsInit")

target(main: "Demonstrate script name abbreviation") {
    println "Showing script name abbreviation in Grails"
}

setDefaultTarget(main)

On the command-line or at the Grails prompt we can now use gG as a script name abbreviation and Grails will invoke the GrailsGoodness script:

$ grails gG
| Environment set to development....
Showing script name abbreviation in Grails

 

 

 

Developers! Quickly and easily gain access to the tools and information you need! Explore, test and combine our data quality APIs at Melissa Developer Portal – home to tools that save time and boost revenue. Our APIs verify, standardize, and correct the Big 4 + more – name, email, phone and global addresses – to ensure accurate delivery, prevent blacklisting and identify risks in real-time.

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}