Skip to content

Commit 46621a1

Browse files
committed
Fix: Correct fetching of plugin in nextflow plugin CLI command via pluginId and version separation
Signed-off-by: Josua Carl <josua.carl@uni-tuebingen.de>
1 parent 6a38ee9 commit 46621a1

1 file changed

Lines changed: 35 additions & 19 deletions

File tree

modules/nextflow/src/main/groovy/nextflow/cli/CmdPlugin.groovy

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,7 @@ class CmdPlugin extends CmdBase {
7575
final target = items[0]
7676
final cmd = items[1] ? items[1..-1].join(CMD_SEP) : null
7777

78-
// push back the command as the first item
79-
Plugins.start(target)
80-
final wrapper = Plugins.manager.getPlugin(target)
81-
if( !wrapper )
82-
throw new AbortOperationException("Cannot find target plugin: $target")
83-
final plugin = wrapper.getPlugin()
84-
if( plugin instanceof PluginExecAware ) {
85-
def mapped = [] as List<String>
86-
params.entrySet().each{
87-
mapped << "--$it.key".toString()
88-
mapped << "$it.value".toString()
89-
}
90-
args.addAll(mapped)
91-
final ret = plugin.exec(getLauncher(), target, cmd, args)
92-
// use explicit exit to invoke the system shutdown hooks
93-
System.exit(ret)
94-
}
95-
else
96-
throw new AbortOperationException("Invalid target plugin: $target")
78+
executeCustomPluginCmd(target, cmd)
9779
}
9880
else {
9981
throw new AbortOperationException("Invalid plugin command: ${args[0]}")
@@ -145,6 +127,40 @@ class CmdPlugin extends CmdBase {
145127
println "Plugin created successfully at path: $targetDir"
146128
}
147129

130+
/**
131+
* Execute a custom CLI command, defined by a plugin.
132+
*
133+
* @param target The target plugin and optional version, Example `nf-somePlugin@1.0.0`
134+
* @param cmd The command that is passed on to the plugin.
135+
*/
136+
private executeCustomPluginCmd(String target, String cmd) {
137+
// Separate ID and version
138+
final List<String> targetSplit = target.tokenize('@') as List<String>
139+
final String pluginId = targetSplit[0]
140+
141+
// push back the command as the first item
142+
Plugins.start(target)
143+
144+
// Fetch started plugin
145+
final wrapper = Plugins.manager.getPlugin(pluginId)
146+
if( !wrapper )
147+
throw new AbortOperationException("Cannot find target plugin: $target")
148+
final plugin = wrapper.getPlugin()
149+
if( plugin instanceof PluginExecAware ) {
150+
def mapped = [] as List<String>
151+
params.entrySet().each{
152+
mapped << "--$it.key".toString()
153+
mapped << "$it.value".toString()
154+
}
155+
args.addAll(mapped)
156+
final ret = plugin.exec(getLauncher(), target, cmd, args)
157+
// use explicit exit to invoke the system shutdown hooks
158+
System.exit(ret)
159+
}
160+
else
161+
throw new AbortOperationException("Invalid target plugin: $target")
162+
}
163+
148164
static private String readLine() {
149165
final console = System.console()
150166
return console != null

0 commit comments

Comments
 (0)