Skip to content

Commit

Permalink
Allows to set a name for the Script Command
Browse files Browse the repository at this point in the history
Closes gh-773
  • Loading branch information
rainboyan committed Dec 3, 2024
1 parent f0d87f8 commit 6891a25
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ abstract class GroovyScriptCommand extends Script implements ProfileCommand, Pro
*/
String grailsVersion = getClass().getPackage()?.getImplementationVersion()

/**
* Provides a name for the command
*
* @param name The name of the command
*/
void name(String name) {
// ignore, just a stub for documentation purposes, populated by CommandScriptTransform
}

/**
* Provides a namespace for the command
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ class GroovyScriptCommandTransform implements ASTTransformation {
constructorBody.addStatement(new ExpressionStatement(assignDescription))
}
}
else if (call.methodAsString == 'name') {
MethodCallExpression setName = new MethodCallExpression(
new VariableExpression('this'), 'setName', call.arguments)
constructorBody.addStatement(new ExpressionStatement(setName))
}
else if (call.methodAsString == 'namespace') {
MethodCallExpression setNamespace = new MethodCallExpression(
new VariableExpression('this'), 'setNamespace', call.arguments)
Expand Down

0 comments on commit 6891a25

Please sign in to comment.