Skip to content

Commit a2063eb

Browse files
committed
Minor improvements
Signed-off-by: Ben Sherman <[email protected]>
1 parent 5f62ff2 commit a2063eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+495
-389
lines changed

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ import nextflow.scm.AssetManager
3333
class CloneImpl {
3434

3535
interface Options extends IHubOptions {
36-
List<String> getArgs()
36+
String getPipeline()
37+
String getTargetName()
3738
String getRevision()
3839
}
3940

@@ -47,13 +48,11 @@ class CloneImpl {
4748
void run() {
4849
// init plugin system
4950
Plugins.init()
50-
// the pipeline name
51-
String pipeline = args[0]
5251
final manager = new AssetManager(pipeline, this)
5352

5453
// the target directory is the second parameter
5554
// otherwise default the current pipeline name
56-
def target = new File(args.size()> 1 ? args[1] : manager.getBaseName())
55+
def target = new File(targetName ?: manager.getBaseName())
5756
if( target.exists() ) {
5857
if( target.isFile() )
5958
throw new AbortOperationException("A file with the same name already exists: $target")

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import nextflow.util.ConfigHelper
3939
class ConfigImpl {
4040

4141
interface Options {
42-
List<String> getArgs()
42+
String getPipeline()
4343
boolean getShowAllProfiles()
4444
String getProfile()
4545
boolean getPrintProperties()
@@ -64,7 +64,7 @@ class ConfigImpl {
6464
void run() {
6565
Plugins.init()
6666
Path base = null
67-
if( args ) base = getBaseDir(args[0])
67+
if( pipeline ) base = getBaseDir(pipeline)
6868
if( !base ) base = Paths.get('.')
6969

7070
if( profile && showAllProfiles ) {

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

+2-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import nextflow.ui.console.ConsoleExtension
3030
class ConsoleImpl {
3131

3232
interface Options {
33-
List<String> getArgs()
33+
String getScript()
3434
}
3535

3636
@Delegate
@@ -46,10 +46,6 @@ class ConsoleImpl {
4646
final console = Plugins.getExtension(ConsoleExtension)
4747
if( !console )
4848
throw new IllegalStateException("Failed to find Nextflow Console extension")
49-
// normalise the console args prepending the `console` command itself
50-
def args1 = args ?: []
51-
args1.add(0, 'console')
52-
// go !
53-
console.run(args1 as String[])
49+
console.run(script)
5450
}
5551
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import nextflow.scm.AssetManager
3333
class DropImpl {
3434

3535
interface Options {
36-
List<String> getArgs()
36+
String getPipeline()
3737
boolean getForce()
3838
}
3939

@@ -46,9 +46,9 @@ class DropImpl {
4646

4747
void run() {
4848
Plugins.init()
49-
def manager = new AssetManager(args[0])
49+
def manager = new AssetManager(pipeline)
5050
if( !manager.localPath.exists() ) {
51-
throw new AbortOperationException("No match found for: ${args[0]}")
51+
throw new AbortOperationException("No match found for: ${pipeline}")
5252
}
5353

5454
if( this.force || manager.isClean() ) {

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import org.yaml.snakeyaml.Yaml
4242
class InfoImpl {
4343

4444
interface Options {
45-
abstract List<String> getArgs()
45+
abstract String getPipeline()
4646
abstract boolean getDetailed()
4747
abstract boolean getMoreDetailed()
4848
abstract String getFormat()
@@ -64,15 +64,15 @@ class InfoImpl {
6464
void run() {
6565

6666
int level = moreDetailed ? 2 : ( detailed ? 1 : 0 )
67-
if( !args ) {
67+
if( !pipeline ) {
6868
println getInfo(level)
6969
return
7070
}
7171

7272
Plugins.init()
73-
final manager = new AssetManager(args[0])
73+
final manager = new AssetManager(pipeline)
7474
if( !manager.isLocal() )
75-
throw new AbortOperationException("Unknown project `${args[0]}`")
75+
throw new AbortOperationException("Unknown project `${pipeline}`")
7676

7777
if( !format || format == 'text' ) {
7878
printText(manager,level)

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class NodeImpl {
3636

3737
interface Options {
3838
Map<String,String> getClusterOptions()
39-
List<String> getArgs()
39+
String getProvider()
4040

4141
ILauncherOptions getLauncherOptions()
4242
}
@@ -50,15 +50,15 @@ class NodeImpl {
5050

5151
void run() {
5252
System.setProperty('nxf.node.daemon', 'true')
53-
launchDaemon(args ? args[0] : null)
53+
launchDaemon(provider)
5454
}
5555

5656
/**
5757
* Launch the daemon service
5858
*
5959
* @param config The nextflow configuration map
6060
*/
61-
protected launchDaemon(String name = null) {
61+
protected launchDaemon(String name) {
6262

6363
// create the config object
6464
def config = new ConfigBuilder()

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

+20-43
Original file line numberDiff line numberDiff line change
@@ -31,54 +31,31 @@ import static nextflow.cli.PluginExecAware.CMD_SEP
3131
@CompileStatic
3232
class PluginImpl {
3333

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)
4537
}
4638

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) {
5140
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
6441

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)
8156
}
57+
else
58+
throw new AbortOperationException("Invalid target plugin: $target")
8259
}
8360

8461
}

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import nextflow.scm.AssetManager
3333
class PullImpl {
3434

3535
interface Options extends IHubOptions {
36-
List<String> getArgs()
36+
String getPipeline()
3737
boolean getAll()
3838
String getRevision()
3939
}
@@ -50,11 +50,11 @@ class PullImpl {
5050

5151
void run() {
5252

53-
if( !all && !args )
54-
throw new AbortOperationException('Missing argument')
53+
if( !pipeline && !all )
54+
throw new AbortOperationException('Project name or option `all` is required')
5555

56-
def list = all ? AssetManager.list() : args.toList()
57-
if( !list ) {
56+
def pipelines = all ? AssetManager.list() : [pipeline]
57+
if( !pipelines ) {
5858
log.info "(nothing to do)"
5959
return
6060
}
@@ -66,8 +66,8 @@ class PullImpl {
6666

6767
// init plugin system
6868
Plugins.init()
69-
70-
list.each {
69+
70+
pipelines.each {
7171
log.info "Checking $it ..."
7272
def manager = new AssetManager(it, this)
7373

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

+5-6
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ import org.yaml.snakeyaml.Yaml
5252
class RunImpl {
5353

5454
interface Options extends IHubOptions {
55+
String getPipeline()
5556
List<String> getArgs()
57+
Map<String,String> getParams()
58+
5659
String getBucketDir()
5760
Boolean getCacheable()
5861
Map<String,String> getClusterOptions()
@@ -69,7 +72,6 @@ class RunImpl {
6972
String getLibPath()
7073
String getMainScript()
7174
boolean getOffline()
72-
Map<String,String> getParams()
7375
String getParamsFile()
7476
String getPlugins()
7577
long getPollInterval()
@@ -82,7 +84,6 @@ class RunImpl {
8284
String getRevision()
8385
List<String> getRunConfig()
8486
String getRunName()
85-
boolean getStdin()
8687
boolean getStubRun()
8788
String getTest()
8889
String getWithApptainer()
@@ -146,8 +147,6 @@ class RunImpl {
146147
}
147148

148149
void run() {
149-
final scriptArgs = (args?.size()>1 ? args[1..-1] : []) as List<String>
150-
final pipeline = stdin ? '-' : ( args ? args[0] : null )
151150
if( !pipeline )
152151
throw new AbortOperationException("No project name was specified")
153152

@@ -218,7 +217,7 @@ class RunImpl {
218217
// set the commit id (if any)
219218
runner.session.commitId = scriptFile.commitId
220219
if( this.test ) {
221-
runner.test(this.test, scriptArgs)
220+
runner.test(this.test, args)
222221
return
223222
}
224223

@@ -229,7 +228,7 @@ class RunImpl {
229228
runner.verifyAndTrackHistory(launcherCliString, runName)
230229

231230
// -- run it!
232-
runner.execute(scriptArgs, this.entryName)
231+
runner.execute(args, this.entryName)
233232
}
234233

235234
protected void checkRunName() {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import nextflow.secret.SecretsProvider
2828
* @author Paolo Di Tommaso <[email protected]>
2929
*/
3030
@CompileStatic
31-
class CmdSecrets {
31+
class SecretsImpl {
3232

3333
enum Command {
3434
GET,

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import nextflow.scm.AssetManager
3333
class ViewImpl {
3434

3535
interface Options {
36-
List<String> getArgs()
36+
String getPipeline()
3737
boolean getQuiet()
3838
boolean getAll()
3939
}
@@ -47,9 +47,9 @@ class ViewImpl {
4747

4848
void run() {
4949
Plugins.init()
50-
def manager = new AssetManager(args[0])
50+
def manager = new AssetManager(pipeline)
5151
if( !manager.isLocal() )
52-
throw new AbortOperationException("Unknown project name `${args[0]}`")
52+
throw new AbortOperationException("Unknown project name `${pipeline}`")
5353

5454
if( all ) {
5555
if( !quiet )

modules/nextflow/src/main/groovy/nextflow/cli/v1/CleanCmd.groovy

+3-5
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ import nextflow.cli.ILauncherOptions
3333
@Parameters(commandDescription = 'Clean up project cache and work directories')
3434
class CleanCmd extends AbstractCmd implements CleanImpl.Options {
3535

36-
static public final String NAME = 'clean'
37-
3836
@Parameter(names = ['-after'], description = 'Clean up runs executed after the specified one')
3937
String after
4038

@@ -56,16 +54,16 @@ class CleanCmd extends AbstractCmd implements CleanImpl.Options {
5654
@Parameter(names = ['-q', '-quiet'], arity = 0, description = 'Do not print names of files removed')
5755
boolean quiet
5856

59-
@Parameter
60-
List<String> args
57+
@Parameter(description = 'Session IDs or run names')
58+
List<String> args = []
6159

6260
@Override
6361
ILauncherOptions getLauncherOptions() {
6462
launcher.options
6563
}
6664

6765
@Override
68-
String getName() { NAME }
66+
String getName() { 'clean' }
6967

7068
@Override
7169
void run() {

modules/nextflow/src/main/groovy/nextflow/cli/v1/CloneCmd.groovy

+10-4
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,22 @@ import nextflow.cli.CloneImpl
3131
@Parameters(commandDescription = 'Clone a project into a folder')
3232
class CloneCmd extends AbstractCmd implements CloneImpl.Options, HubOptions {
3333

34-
static public final String NAME = 'clone'
35-
3634
@Parameter(required = true, description = 'name of the project to clone')
3735
List<String> args
3836

39-
@Parameter(names = ['-r'], description = 'Revision to clone - It can be a git branch, tag or revision number')
37+
@Parameter(names = ['-r','-revision'], description = 'Revision to clone - It can be a git branch, tag or revision number')
4038
String revision
4139

4240
@Override
43-
String getName() { NAME }
41+
String getPipeline() { args[0] }
42+
43+
@Override
44+
String getTargetName() {
45+
args.size() > 1 ? args[1] : null
46+
}
47+
48+
@Override
49+
String getName() { 'clone' }
4450

4551
@Override
4652
void run() {

0 commit comments

Comments
 (0)