First, I'm sorry but this is kind of a "give me teh codez" question. I promise to learn from your answers, though! That means that feel free to use the Socratic method if you feel it's necessary.
I'm currently developing (both maintenance and building new ones) multiple sites using Grails and the way it works is that it provides a commandline shell for executing various tasks.
This is all fine and well, but switching between versions is a bit of a nuisance, since it's all controlled by a single environment variable called GRAILS_HOME
which is set to point to a directory such as C:\grails\grails-1.2.3\
.
Now, what I would like to be able to do that instead of doing something like this:
grails create-app MyWebApp
grails list-plugins -repository=myPluginRepo
grails install-plugin myPlugin
and then noticing that I'm using the wrong version and that I have to go back, I'd rather do
g135 create-app MyWebApp
g135 list-plugins -repository=myPluginRepo
g135 install-plugin myPlugin
w开发者_开发知识库hich would immediately tell me that I'm using Grails 1.3.5.
The problem I have in creating a psh script like this is that I absolutely suck at creating scripts. I did try doing this but after about five mysterious error messages from psh itself I decided to just ask for advice.
Bonus points: If I can parameterize the alias call to specify the version (something like g[1.3.5] other params
) and then append the number to the environment variable value,
that'd be the most handy solution for me.
This should do it:
Function PSGrails($ver)
{
$env:GRAILS_HOME='c:\grails\grails-{0}\' -f $ver
grails $args
}
It's just a short function that sets the variable and then executes grails as above.
Run it by specifying the version number directly after the function name:
psgrails 1.3.5 create-app MyWebApp
psgrails 1.3.5 list-plugins -repository=myPluginRepo
psgrails 1.3.5 install-plugin myPlugin
精彩评论