Skip to content

Commit 6891a25

Browse files
committed
Allows to set a name for the Script Command
Closes gh-773
1 parent f0d87f8 commit 6891a25

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

grace-shell/src/main/groovy/org/grails/cli/profile/commands/script/GroovyScriptCommand.groovy

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ abstract class GroovyScriptCommand extends Script implements ProfileCommand, Pro
9393
*/
9494
String grailsVersion = getClass().getPackage()?.getImplementationVersion()
9595

96+
/**
97+
* Provides a name for the command
98+
*
99+
* @param name The name of the command
100+
*/
101+
void name(String name) {
102+
// ignore, just a stub for documentation purposes, populated by CommandScriptTransform
103+
}
104+
96105
/**
97106
* Provides a namespace for the command
98107
*

grace-shell/src/main/groovy/org/grails/cli/profile/commands/script/GroovyScriptCommandTransform.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ class GroovyScriptCommandTransform implements ASTTransformation {
133133
constructorBody.addStatement(new ExpressionStatement(assignDescription))
134134
}
135135
}
136+
else if (call.methodAsString == 'name') {
137+
MethodCallExpression setName = new MethodCallExpression(
138+
new VariableExpression('this'), 'setName', call.arguments)
139+
constructorBody.addStatement(new ExpressionStatement(setName))
140+
}
136141
else if (call.methodAsString == 'namespace') {
137142
MethodCallExpression setNamespace = new MethodCallExpression(
138143
new VariableExpression('this'), 'setNamespace', call.arguments)

0 commit comments

Comments
 (0)