I work under some DSLs using the Groovy categories, and I would like to find a way to use my DSL with the Groovy shell without an explicit entry use(MyCategory){ myObject.doSomething() }for each command.
For example, suppose I have the following category of toys:
class MyCategory {
static Integer plus(Integer integer, String string){
return integer + Integer.valueOf(string)
}
}
Then I can use this category in the groovyshfollowing way:
groovy> use(MyCategory){ 2 + '3' }
So, is there a way to configure MyCategoryglobally for all teams groovysh, so there is no need to wrap my commands every time in use(MyCategory) { ... }? For instance:
groovy> useGlobally(MyCategory);
groovy> 2 + '3'
source
share