@@ -31,54 +31,31 @@ import static nextflow.cli.PluginExecAware.CMD_SEP
31
31
@CompileStatic
32
32
class PluginImpl {
33
33
34
- interface Options {
35
- List<String > getArgs ()
36
-
37
- ILauncherOptions getLauncherOptions ()
38
- }
39
-
40
- @Delegate
41
- private Options options
42
-
43
- PluginImpl (Options options ) {
44
- this . options = options
34
+ static void install (List<String > ids ) {
35
+ Plugins . setup()
36
+ Plugins . pull(ids)
45
37
}
46
38
47
- void run () {
48
- if ( ! args )
49
- throw new AbortOperationException (" Missing plugin command - usage: nextflow plugin install <pluginId,..>" )
50
- // setup plugins system
39
+ static void exec (String command , List<String > args , ILauncherOptions launcherOptions ) {
51
40
Plugins . setup()
52
- // check for the plugins install
53
- if ( args[0 ] == ' install' ) {
54
- if ( args. size()!= 2 )
55
- throw new AbortOperationException (" Missing plugin install target - usage: nextflow plugin install <pluginId,..>" )
56
- Plugins . pull(args[1 ]. tokenize(' ,' ))
57
- }
58
- // plugin run command
59
- else if ( args[0 ]. contains(CMD_SEP ) ) {
60
- final head = args. pop()
61
- final items = head. tokenize(CMD_SEP )
62
- final target = items[0 ]
63
- final cmd = items[1 ] ? items[1 .. -1 ]. join(CMD_SEP ) : null
64
41
65
- // push back the command as the first item
66
- Plugins . start(target)
67
- final wrapper = Plugins . manager. getPlugin(target)
68
- if ( ! wrapper )
69
- throw new AbortOperationException (" Cannot find target plugin: $target " )
70
- final plugin = wrapper. getPlugin()
71
- if ( plugin instanceof PluginExecAware ) {
72
- final ret = plugin. exec(launcherOptions, target, cmd, args)
73
- // use explicit exit to invoke the system shutdown hooks
74
- System . exit(ret)
75
- }
76
- else
77
- throw new AbortOperationException (" Invalid target plugin: $target " )
78
- }
79
- else {
80
- throw new AbortOperationException (" Invalid plugin command: ${ args[0]} " )
42
+ final items = command. tokenize(CMD_SEP )
43
+ final target = items[0 ]
44
+ final targetCmd = items[1 ] ? items[1 .. -1 ]. join(CMD_SEP ) : null
45
+
46
+ // push back the command as the first item
47
+ Plugins . start(target)
48
+ final wrapper = Plugins . manager. getPlugin(target)
49
+ if ( ! wrapper )
50
+ throw new AbortOperationException (" Cannot find target plugin: $target " )
51
+ final plugin = wrapper. getPlugin()
52
+ if ( plugin instanceof PluginExecAware ) {
53
+ final ret = plugin. exec(launcherOptions, target, targetCmd, args)
54
+ // use explicit exit to invoke the system shutdown hooks
55
+ System . exit(ret)
81
56
}
57
+ else
58
+ throw new AbortOperationException (" Invalid target plugin: $target " )
82
59
}
83
60
84
61
}
0 commit comments