sheehan / grails-console

A web-based Groovy console for interactive runtime application management and debugging
Apache License 2.0
78 stars 41 forks source link

Add implicit variables / template for new file #32

Closed ryanberckmans closed 9 years ago

ryanberckmans commented 9 years ago

We use grails-console 1.5.3.

Is it possible to have new console files use a specific template?

Whenever I create a new file, I always start with:

import my.thing.*

def myService = ctx.getBean('myService').YayBusiness.getProfit();
...

It would be extremely helpful to set a template which gave us more to work with for new files. Thanks

sheehan commented 9 years ago

Specified as a config param?

ryanberckmans commented 9 years ago

A config param would be fine, e.g. Config.groovy:

grails-console {
    newFileContents = "import my.thing.*; def myService = ctx.getBean('myService'); ....."
}

A better solution might be something like resources/grails-console-new-file.groovy, and in Config.groovy grails-console.newFileTemplate = 'resources/grails-console-new-file.groovy.

I can see our new file template becoming very complex. Load classes, helpers, all sorts of boilerplate. We have many common operations used to debug + one-off maintenance tasks.

Thanks for your attention - this change would be a big help to us.

ryanberckmans commented 9 years ago

Having just experience this personally, it would be extremely valuable to execute a block of code to determine what text is displayed in the new file.

I want my production console to say "WARNING PRODUCTION" :+1:

I just accidentally ran a (blessedly read-only) command in production instead of development. So in my case, I'll case on BuildConfig.ENVIRONMENT (or whatever it actually is) to set my file template, and the production template will have warnings.

ryanberckmans commented 9 years ago

Thanks! Love it. Any timeline on new 1.X release? (We're on grails 2).

I see https://grails.org/plugin/console --> Last Updated: 25 February 2015

sheehan commented 9 years ago

v1.5.5 should be available now