support custom groovy scripts (via files)

This commit is contained in:
Reinhard Pointner 2019-06-07 19:24:35 +07:00
parent 62238e507e
commit dbcddd02e3
2 changed files with 8 additions and 3 deletions

View File

@ -232,17 +232,22 @@ public class ArgumentBean {
return files;
}
public RenameAction getRenameAction() {
public RenameAction getRenameAction() throws Exception {
// support custom executables (via absolute path)
if (action.startsWith("/")) {
return new ExecutableRenameAction(action, getOutputPath());
}
// support custom groovy scripts (via closures)
if (action.startsWith("{")) {
if (action.startsWith("{") || action.endsWith("}")) {
return new GroovyRenameAction(action);
}
// support custom groovy scripts (via files)
if (action.endsWith(".groovy")) {
return new GroovyRenameAction(readTextFile(new File(action)));
}
return StandardRenameAction.forName(action);
}

View File

@ -512,7 +512,7 @@ public abstract class ScriptShellBaseClass extends Script {
return map;
}
private RenameAction getRenameAction(Map<String, ?> parameters) {
private RenameAction getRenameAction(Map<String, ?> parameters) throws Exception {
return consumeParameter(parameters, "action").map(action -> {
return getRenameAction(action);
}).findFirst().orElse(getArgumentBean().getRenameAction()); // default to global rename action