diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CliOptions.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CliOptions.groovy new file mode 100644 index 0000000000..f9a94266c9 --- /dev/null +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CliOptions.groovy @@ -0,0 +1,137 @@ +/* + * Copyright 2020-2022, Seqera Labs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package nextflow.cli + +import com.beust.jcommander.DynamicParameter +import com.beust.jcommander.Parameter +import groovy.util.logging.Slf4j +import nextflow.exception.AbortOperationException +import org.fusesource.jansi.Ansi + +/** + * Interface for top-level CLI options. + * + * @author Paolo Di Tommaso + */ +@Slf4j +trait CliOptions { + + abstract Boolean getAnsiLogCli() + + abstract boolean isBackground() + + abstract List getConfig() + + abstract List getDebug() + + abstract boolean getIgnoreConfigIncludes() + + abstract String getLogFile() + + abstract boolean isQuiet() + + abstract String getSyslog() + + abstract List getTrace() + + abstract List getUserConfig() + + abstract void setAnsiLog(boolean value) + + abstract void setBackground(boolean value) + + static class V1 implements CliOptions { + + Boolean ansiLogCli + + void setAnsiLog(boolean value) { ansiLogCli = value } + + @Parameter(names = ['-bg'], arity = 0, description = 'Execute nextflow in background') + boolean background + + @Parameter(names = ['-C'], description = 'Use the specified configuration file(s) overriding any defaults') + List config + + @Parameter(names = ['-c','-config'], description = 'Add the specified file to configuration set') + List userConfig + + @Parameter(names = ['-config-ignore-includes'], description = 'Disable the parsing of config includes') + boolean ignoreConfigIncludes + + @DynamicParameter(names = ['-D'], description = 'Set JVM properties' ) + Map jvmOpts = [:] + + @Parameter(names = ['-debug'], hidden = true) + List debug + + @Parameter(names = ['-d','-dockerize'], arity = 0, description = 'Launch nextflow via Docker (experimental)') + boolean dockerize + + @Parameter(names = ['-h'], description = 'Print this help', help = true) + boolean help + + @Parameter(names = ['-log'], description = 'Set nextflow log file path') + String logFile + + @Parameter(names = ['-q','-quiet'], description = 'Do not print information messages' ) + boolean quiet + + @Parameter(names = ['-self-update'], arity = 0, description = 'Update nextflow to the latest version', hidden = true) + boolean selfUpdate + + @Parameter(names = ['-syslog'], description = 'Send logs to syslog server (eg. localhost:514)' ) + String syslog + + @Parameter(names = ['-trace'], description = 'Enable trace level logging for the specified package name - multiple packages can be provided separating them with a comma e.g. \'-trace nextflow,io.seqera\'') + List trace + + @Parameter(names = ['-v'], description = 'Print the program version') + boolean version + + @Parameter(names = ['-version'], description = 'Print the program version (full)') + boolean fullVersion + + } + + boolean getAnsiLog() { + if( ansiLogCli && quiet ) + throw new AbortOperationException("Command line options `quiet` and `ansi-log` cannot be used together") + + if( ansiLogCli != null ) + return ansiLogCli + + if( background ) + return ansiLogCli = false + + if( quiet ) + return ansiLogCli = false + + final env = System.getenv('NXF_ANSI_LOG') + if( env ) try { + return Boolean.parseBoolean(env) + } + catch (Exception e) { + log.warn "Invalid boolean value for variable NXF_ANSI_LOG: $env -- it must be 'true' or 'false'" + } + return Ansi.isEnabled() + } + + boolean hasAnsiLogFlag() { + ansiLogCli==true || System.getenv('NXF_ANSI_LOG')=='true' + } + +} diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdClean.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdClean.groovy index dad1f9cf3f..c54da7341e 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdClean.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdClean.groovy @@ -49,6 +49,8 @@ import nextflow.util.HistoryFile.Record @CompileStatic class CmdClean implements CacheBase { + static final public NAME = 'clean' + interface Options { String getAfter() String getBefore() @@ -59,7 +61,7 @@ class CmdClean implements CacheBase { boolean getQuiet() List getArgs() - ILauncherOptions getLauncherOptions() + CliOptions getLauncherOptions() } @Parameters(commandDescription = 'Clean up project cache and work directories') @@ -90,12 +92,12 @@ class CmdClean implements CacheBase { List args @Override - ILauncherOptions getLauncherOptions() { + CliOptions getLauncherOptions() { launcher.options } @Override - String getName() { 'clean' } + String getName() { NAME } @Override void run() { diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdClone.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdClone.groovy index 2bab613963..0e36d89248 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdClone.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdClone.groovy @@ -31,15 +31,17 @@ import nextflow.scm.AssetManager @CompileStatic class CmdClone { - interface Options extends IHubOptions { + static final public NAME = 'clone' + + interface Options extends HubOptions { String getPipeline() String getTargetName() Integer getDeep() String getRevision() } - @Parameters(commandDescription = 'Clone a project into a folder') - static class V1 extends CmdBase implements Options, HubOptions { + @Parameters(commandDescription = "Clone a project into a folder") + static class V1 extends CmdBase implements Options, HubOptions.V1 { @Parameter(required=true, description = 'name of the project to clone') List args @@ -59,7 +61,7 @@ class CmdClone { } @Override - String getName() { 'clone' } + final String getName() { NAME } @Override void run() { diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdConfig.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdConfig.groovy index 29fa27ea12..a5004a1754 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdConfig.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdConfig.groovy @@ -38,6 +38,8 @@ import nextflow.util.ConfigHelper @CompileStatic class CmdConfig { + static final public NAME = 'config' + interface Options { String getPipeline() boolean getShowAllProfiles() @@ -46,10 +48,10 @@ class CmdConfig { boolean getPrintFlatten() boolean getSort() - ILauncherOptions getLauncherOptions() + CliOptions getLauncherOptions() } - @Parameters(commandDescription = 'Print a project configuration') + @Parameters(commandDescription = "Print a project configuration") static class V1 extends CmdBase implements Options { @Parameter(description = 'project name') @@ -76,12 +78,12 @@ class CmdConfig { } @Override - ILauncherOptions getLauncherOptions() { + CliOptions getLauncherOptions() { launcher.options } @Override - String getName() { 'config' } + String getName() { NAME } @Override void run() { diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdConsole.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdConsole.groovy index b520cc505e..a1b9360d4b 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdConsole.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdConsole.groovy @@ -34,7 +34,7 @@ class CmdConsole { String getScript() } - @Parameters(commandDescription = 'Launch Nextflow interactive console') + @Parameters(commandDescription = "Launch Nextflow interactive console") static class V1 extends CmdBase implements Options { @Parameter(description = 'Nextflow console arguments') diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdDrop.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdDrop.groovy index 7f4d6dda0a..0b74ad22a9 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdDrop.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdDrop.groovy @@ -33,12 +33,14 @@ import nextflow.scm.AssetManager @CompileStatic class CmdDrop { + static final public NAME = 'drop' + interface Options { String getPipeline() boolean getForce() } - @Parameters(commandDescription = 'Delete the local copy of a project') + @Parameters(commandDescription = "Delete the local copy of a project") static class V1 extends CmdBase implements Options { @Parameter(required=true, description = 'name of the project to drop') @@ -51,7 +53,7 @@ class CmdDrop { String getPipeline() { args[0] } @Override - String getName() { 'drop' } + final String getName() { NAME } @Override void run() { diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdFs.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdFs.groovy index aeca483ab0..fac647c46f 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdFs.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdFs.groovy @@ -36,6 +36,8 @@ import nextflow.plugin.Plugins @CompileStatic class CmdFs { + static final public NAME = 'fs' + enum Command { COPY, MOVE, @@ -48,9 +50,12 @@ class CmdFs { static class V1 extends CmdBase implements UsageAware { trait SubCmd { - abstract String getName() abstract int getArity() + + abstract String getName() + abstract String getDescription() + abstract Command getCommand() String usage() { @@ -58,6 +63,86 @@ class CmdFs { } } + static class CmdCopy implements SubCmd { + + @Override + int getArity() { 2 } + + @Override + String getName() { 'cp' } + + @Override + String getDescription() { 'Copy a file' } + + @Override + Command getCommand() { Command.COPY } + + } + + static class CmdMove implements SubCmd { + + @Override + int getArity() { 2 } + + @Override + String getName() { 'mv' } + + @Override + String getDescription() { 'Move a file' } + + @Override + Command getCommand() { Command.MOVE } + + } + + static class CmdList implements SubCmd { + + @Override + int getArity() { 1 } + + @Override + String getDescription() { 'List the content of a folder' } + + @Override + String getName() { 'ls' } + + @Override + Command getCommand() { Command.LIST } + + } + + static class CmdCat implements SubCmd { + + @Override + int getArity() { 1 } + + @Override + String getName() { 'cat' } + + @Override + String getDescription() { 'Print a file to the stdout' } + + @Override + Command getCommand() { Command.CAT } + + } + + static class CmdRemove implements SubCmd { + + @Override + int getArity() { 1 } + + @Override + String getName() { 'rm' } + + @Override + String getDescription() { 'Remove a file' } + + @Override + Command getCommand() { Command.REMOVE } + + } + private List commands = (List)[ new CmdCopy(), new CmdMove(), @@ -66,11 +151,13 @@ class CmdFs { new CmdRemove() ] - @Parameter(hidden = true) - List args = [] + @Parameter + List args @Override - String getName() { 'fs' } + String getName() { + return NAME + } @Override void run() { @@ -79,13 +166,9 @@ class CmdFs { return } - final cmd = commands.find { it.name == args[0] } + final cmd = findCmd(args[0]) if( !cmd ) { - def matches = commands.collect{ it.name }.closest(args[0]) - def msg = "Unknown fs sub-command: ${args[0]}" - if( matches ) - msg += " -- Did you mean one of these?\n" + matches.collect { " $it"}.join('\n') - throw new AbortOperationException(msg) + throw new AbortOperationException("Unknown file system command: `$cmd`") } if( args.size() - 1 != cmd.getArity() ) @@ -94,6 +177,10 @@ class CmdFs { new CmdFs().run(cmd.getCommand(), args.drop(1)) } + private SubCmd findCmd( String name ) { + commands.find { it.name == name } + } + /** * Print the command usage help */ @@ -120,49 +207,13 @@ class CmdFs { println result.join('\n').toString() } else { - def sub = commands.find { it.name == args[0] } + def sub = findCmd(args[0]) if( sub ) println sub.usage() else { throw new AbortOperationException("Unknown fs sub-command: ${args[0]}") } } - - } - - static class CmdCopy implements SubCmd { - @Override String getName() { 'cp' } - @Override int getArity() { 2 } - @Override String getDescription() { 'Copy a file' } - @Override Command getCommand() { Command.COPY } - } - - static class CmdMove implements SubCmd { - @Override String getName() { 'mv' } - @Override int getArity() { 2 } - @Override String getDescription() { 'Move a file' } - @Override Command getCommand() { Command.MOVE } - } - - static class CmdList implements SubCmd { - @Override String getName() { 'ls' } - @Override int getArity() { 1 } - @Override String getDescription() { 'List the contents of a folder' } - @Override Command getCommand() { Command.LIST } - } - - static class CmdCat implements SubCmd { - @Override String getName() { 'cat' } - @Override int getArity() { 1 } - @Override String getDescription() { 'Print a file to stdout' } - @Override Command getCommand() { Command.CAT } - } - - static class CmdRemove implements SubCmd { - @Override String getName() { 'rm' } - @Override int getArity() { 1 } - @Override String getDescription() { 'Remove a file' } - @Override Command getCommand() { Command.REMOVE } } } @@ -171,30 +222,35 @@ class CmdFs { Plugins.setup() try { - switch( command ) { - case COPY: - traverse(args[0]) { Path path -> copy(path, args[1] as Path) } - break - case MOVE: - traverse(args[0]) { Path path -> move(path, args[1] as Path) } - break - case LIST: - traverse(args[0]) { Path path -> list(path) } - break - case CAT: - traverse(args[0]) { Path path -> cat(path) } - break - case REMOVE: - traverse(args[0]) { Path path -> remove(path) } - break - } + run0(command, args) } finally { Plugins.stop() } } + private void run0(Command command, List args) { + switch( command ) { + case COPY: + traverse(args[0]) { Path path -> copy(path, args[1] as Path) } + break + case MOVE: + traverse(args[0]) { Path path -> move(path, args[1] as Path) } + break + case LIST: + traverse(args[0]) { Path path -> list(path) } + break + case CAT: + traverse(args[0]) { Path path -> cat(path) } + break + case REMOVE: + traverse(args[0]) { Path path -> remove(path) } + break + } + } + private void traverse( String source, Closure op ) { + // if it isn't a glob pattern simply return it a normalized absolute Path object def splitter = FilePatternSplitter.glob().parse(source) if( splitter.isPattern() ) { @@ -212,6 +268,7 @@ class CmdFs { def normalised = splitter.strip(source) op.call(FileHelper.asPath(normalised)) } + } void copy(Path source, Path target) { diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdInfo.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdInfo.groovy index 211ce598ab..8c34552c45 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdInfo.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdInfo.groovy @@ -42,6 +42,8 @@ import org.yaml.snakeyaml.Yaml @CompileStatic class CmdInfo { + static final public NAME = 'info' + interface Options { abstract String getPipeline() abstract boolean getDetailed() @@ -74,7 +76,7 @@ class CmdInfo { } @Override - String getName() { 'info' } + final String getName() { NAME } @Override void run() { diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdList.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdList.groovy index 97cf426ad3..1ba32d780f 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdList.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdList.groovy @@ -30,13 +30,15 @@ import nextflow.scm.AssetManager @CompileStatic class CmdList { + static final public NAME = 'list' + interface Options {} - @Parameters(commandDescription = 'List all downloaded projects') + @Parameters(commandDescription = "List all downloaded projects") static class V1 extends CmdBase implements Options { @Override - String getName() { 'list' } + final String getName() { NAME } @Override void run() { diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdLog.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdLog.groovy index ab777302b7..bb478aa1d0 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdLog.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdLog.groovy @@ -56,6 +56,8 @@ class CmdLog implements CacheBase { ALL_FIELDS.sort(true) } + static final public NAME = 'log' + interface Options { String getAfter() String getBefore() @@ -69,7 +71,7 @@ class CmdLog implements CacheBase { List getArgs() } - @Parameters(commandDescription = 'Print executions log and runtime info') + @Parameters(commandDescription = "Print executions log and runtime info") static class V1 extends CmdBase implements Options { @Parameter(names = ['-s'], description='Character used to separate column values') @@ -103,7 +105,7 @@ class CmdLog implements CacheBase { List args @Override - String getName() { 'log' } + final String getName() { NAME } @Override void run() { diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdNode.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdNode.groovy index 20e731566e..a827f3dc60 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdNode.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdNode.groovy @@ -33,14 +33,16 @@ import nextflow.util.ServiceDiscover @CompileStatic class CmdNode { + static final public NAME = 'node' + interface Options { Map getClusterOptions() String getProvider() - ILauncherOptions getLauncherOptions() + CliOptions getLauncherOptions() } - @Parameters(commandDescription = 'Launch Nextflow in deamon mode') + @Parameters(commandDescription = 'Launch Nextflow in daemon mode') static class V1 extends CmdBase implements Options { @DynamicParameter(names ='-cluster.', description='Define cluster config options') @@ -60,12 +62,12 @@ class CmdNode { } @Override - ILauncherOptions getLauncherOptions() { + CliOptions getLauncherOptions() { launcher.options } @Override - String getName() { 'node' } + String getName() { NAME } @Override void run() { diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdPlugin.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdPlugin.groovy index d7fe9f7122..02d058bf53 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdPlugin.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdPlugin.groovy @@ -32,27 +32,27 @@ import static nextflow.cli.PluginExecAware.CMD_SEP @CompileStatic class CmdPlugin { - @Parameters(commandDescription = 'Manage plugins and execute custom plugin commands') + @Parameters(commandDescription = "Execute plugin-specific commands") static class V1 extends CmdBase { + @Override + String getName() { + return 'plugin' + } + @Parameter(hidden = true) List args - @Override - String getName() { 'plugin' } - @Override void run() { if( !args ) throw new AbortOperationException("Missing plugin command - usage: nextflow plugin install ") - // plugin install command if( args[0] == 'install' ) { if( args.size()!=2 ) throw new AbortOperationException("Missing plugin install target - usage: nextflow plugin install ") CmdPlugin.install(args[1].tokenize(',')) } - // plugin run command else if( args[0].contains(CMD_SEP) ) { CmdPlugin.exec(args.pop(), args, launcher.options) @@ -70,12 +70,12 @@ class CmdPlugin { Plugins.pull(ids) } - static void exec(String command, List args, ILauncherOptions launcherOptions) { + static void exec(String head, List args, CliOptions launcherOptions) { Plugins.setup() - final items = command.tokenize(CMD_SEP) + final items = head.tokenize(CMD_SEP) final target = items[0] - final targetCmd = items[1] ? items[1..-1].join(CMD_SEP) : null + final cmd = items[1] ? items[1..-1].join(CMD_SEP) : null // push back the command as the first item Plugins.start(target) @@ -84,7 +84,7 @@ class CmdPlugin { throw new AbortOperationException("Cannot find target plugin: $target") final plugin = wrapper.getPlugin() if( plugin instanceof PluginExecAware ) { - final ret = plugin.exec(launcherOptions, target, targetCmd, args) + final ret = plugin.exec(launcherOptions, target, cmd, args) // use explicit exit to invoke the system shutdown hooks System.exit(ret) } diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdPull.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdPull.groovy index 7431ca4f7d..a22789b674 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdPull.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdPull.groovy @@ -31,15 +31,17 @@ import nextflow.scm.AssetManager @CompileStatic class CmdPull { - interface Options extends IHubOptions { + static final public NAME = 'pull' + + interface Options extends HubOptions { String getPipeline() boolean getAll() Integer getDeep() String getRevision() } - @Parameters(commandDescription = 'Download or update a project') - static class V1 extends CmdBase implements Options, HubOptions { + @Parameters(commandDescription = "Download or update a project") + static class V1 extends CmdBase implements Options, HubOptions.V1 { @Parameter(description = 'project name or repository url to pull', arity = 1) List args @@ -57,7 +59,7 @@ class CmdPull { String getPipeline() { args[0] } @Override - String getName() { 'pull' } + final String getName() { NAME } @Override void run() { @@ -78,7 +80,7 @@ class CmdPull { void run() { - if( !pipeline && !all ) + if( !all && !pipeline ) throw new AbortOperationException('Project name or option `-all` is required') def list = all ? AssetManager.list() : [pipeline] diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy index 74f6bcda4c..f1cfb1857b 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy @@ -55,7 +55,9 @@ import org.yaml.snakeyaml.Yaml @CompileStatic class CmdRun { - interface Options extends IHubOptions { + static final public String NAME = 'run' + + interface Options extends HubOptions { String getPipeline() List getArgs() Map getParams() @@ -115,7 +117,7 @@ class CmdRun { String getWorkDir() String getLauncherCliString() - ILauncherOptions getLauncherOptions() + CliOptions getLauncherOptions() void setRunName(String runName) } @@ -132,8 +134,8 @@ class CmdRun { GParsConfig.poolFactory = new CustomPoolFactory() } - @Parameters(commandDescription = 'Execute a pipeline project') - static class V1 extends CmdBase implements Options, HubOptions { + @Parameters(commandDescription = "Execute a pipeline project") + static class V1 extends CmdBase implements Options, HubOptions.V1 { static class DurationConverter implements IStringConverter { @Override @@ -304,7 +306,7 @@ class CmdRun { Boolean withoutSpack @Parameter(names=['-offline'], description = 'Do not check for remote project updates') - boolean offline = System.getenv('NXF_OFFLINE')=='true' + boolean offline @Parameter(names=['-entry'], description = 'Entry workflow name to be executed', arity = 1) String entryName @@ -346,12 +348,12 @@ class CmdRun { } @Override - ILauncherOptions getLauncherOptions() { + CliOptions getLauncherOptions() { launcher.options } @Override - String getName() { 'run' } + String getName() { NAME } @Override void run() { @@ -373,21 +375,21 @@ class CmdRun { CmdRun() {} Boolean getDisableJobsCancellation() { - options.disableJobsCancellation != null + return options.disableJobsCancellation!=null ? options.disableJobsCancellation : sysEnv.get('NXF_DISABLE_JOBS_CANCELLATION') as boolean } boolean getOffline() { - options.offline || System.getenv('NXF_OFFLINE') as boolean + return options.offline || System.getenv('NXF_OFFLINE') as boolean } String getParamsFile() { - options.paramsFile ?: sysEnv.get('NXF_PARAMS_FILE') + return options.paramsFile ?: sysEnv.get('NXF_PARAMS_FILE') } boolean hasParams() { - options.params || getParamsFile() + return options.params || getParamsFile() } void run() { diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdSecret.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdSecret.groovy index 9296d47a08..332a672f50 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdSecret.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdSecret.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2020-2022, Seqera Labs + * Copyright 2013-2023, Seqera Labs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,15 +25,16 @@ import nextflow.exception.AbortOperationException import nextflow.plugin.Plugins import nextflow.secret.SecretsLoader import nextflow.secret.SecretsProvider - /** - * CLI `secrets` sub-command + * Implements the {@code secret} command * * @author Paolo Di Tommaso */ @Slf4j @CompileStatic -class CmdSecrets { +class CmdSecret { + + static public final String NAME = 'secrets' enum Command { GET, @@ -42,45 +43,30 @@ class CmdSecrets { DELETE } - @Parameters(commandDescription = 'Manage pipeline secrets (preview)') + @Parameters(commandDescription = "Manage pipeline secrets (preview)") static class V1 extends CmdBase implements UsageAware { interface SubCmd { String getName() - void apply(List args) - void usage(List args) + void apply(List result) + void usage(List result) } - private List commands = (List)[ - new GetCmd(), - new SetCmd(), - new ListCmd(), - new DeleteCmd() - ] - - @Parameter(hidden = true) - List args = [] - - @Override - String getName() { 'secrets' } - - @Override - void run() { - if( !args ) { - usage() - return - } + private List commands = [] - final cmd = commands.find { it.name == args[0] } - if( !cmd ) { - def matches = commands.collect{ it.name }.closest(args[0]) - def msg = "Unknown secrets sub-command: ${args[0]}" - if( matches ) - msg += " -- Did you mean one of these?\n" + matches.collect { " $it"}.join('\n') - throw new AbortOperationException(msg) - } + String getName() { + return NAME + } - cmd.apply(args.drop(1)) + @Parameter(hidden = true) + List args + + V1() { + commands.add( new GetCmd() ) + commands.add( new PutCmd() ) + commands.add( new SetCmd() ) + commands.add( new ListCmd() ) + commands.add( new DeleteCmd() ) } /** @@ -120,11 +106,35 @@ class CmdSecrets { println result.join('\n').toString() } - private void addOption(String fieldName, List args) { + @Override + void run() { + if( !args ) { + usage() + return + } + + getCmd(args).apply(args.drop(1)) + } + + protected SubCmd getCmd(List args) { + + def cmd = commands.find { it.name == args[0] } + if( cmd ) { + return cmd + } + + def matches = commands.collect{ it.name }.closest(args[0]) + def msg = "Unknown secrets sub-command: ${args[0]}" + if( matches ) + msg += " -- Did you mean one of these?\n" + matches.collect { " $it"}.join('\n') + throw new AbortOperationException(msg) + } + + private void addOption(String fieldName, List result) { def annot = this.class.getDeclaredField(fieldName)?.getAnnotation(Parameter) if( annot ) { - args << ' ' + annot.names().join(', ') - args << ' ' + annot.description() + result << ' ' + annot.names().join(', ') + result << ' ' + annot.description() } else { log.debug "Unknown help field: $fieldName" @@ -136,55 +146,58 @@ class CmdSecrets { @Override String getName() { 'put' } - void apply(List args) { + @Override + void apply(List result) { log.warn "Put command is deprecated - use 'set' instead'" - super.apply(args) + super.apply(result) } } class SetCmd implements SubCmd { + @Override String getName() { 'set' } @Override - void apply(List args) { - if( args.size() < 1 ) + void apply(List result) { + if( result.size() < 1 ) throw new AbortOperationException("Missing secret name") - if( args.size() < 2 ) + if( result.size() < 2 ) throw new AbortOperationException("Missing secret value") - new CmdSecrets().run(Command.SET, args) + new CmdSecret().run(Command.SET, result) } @Override - void usage(List args) { - args << 'Set a key-pair in the secrets store' - args << "Usage: nextflow secrets $name ".toString() - args << '' - args << '' + void usage(List result) { + result << 'Set a key-pair in the secrets store' + result << "Usage: nextflow secrets $name ".toString() + result << '' + result << '' } } class GetCmd implements SubCmd { + @Override String getName() { 'get' } @Override - void apply(List args) { - if( args.size() != 1 ) + void apply(List result) { + if( result.size() != 1 ) throw new AbortOperationException("Wrong number of arguments") - if( !args[0] ) + if( !result.first() ) throw new AbortOperationException("Missing secret name") - new CmdSecrets().run(Command.GET, args) + new CmdSecret().run(Command.GET, result) } @Override - void usage(List args) { - args << 'Get a secret value with the name' - args << "Usage: nextflow secrets $name ".toString() - args << '' + void usage(List result) { + result << 'Get a secret value with the name' + result << "Usage: nextflow secrets $name ".toString() + result << '' } } @@ -193,18 +206,18 @@ class CmdSecrets { String getName() { 'list' } @Override - void apply(List args) { - if( args.size() > 0 ) + void apply(List result) { + if( result.size() > 0 ) throw new AbortOperationException("Wrong number of arguments") - new CmdSecrets().run(Command.LIST, args) + new CmdSecret().run(Command.LIST, result) } @Override - void usage(List args) { - args << 'List all names in the secrets store' - args << "Usage: nextflow secrets $name".toString() - args << '' + void usage(List result) { + result << 'List all names in the secrets store' + result << "Usage: nextflow secrets $name".toString() + result << '' } } @@ -213,23 +226,23 @@ class CmdSecrets { String getName() { 'delete' } @Override - void apply(List args) { - if( args.size() != 1 ) + void apply(List result) { + if( result.size() != 1 ) throw new AbortOperationException("Wrong number of arguments") - if( !args[0] ) + if( !result.first() ) throw new AbortOperationException("Missing secret name") - new CmdSecrets().run(Command.DELETE, args) + new CmdSecret().run(Command.DELETE, result) } @Override - void usage(List args) { - args << 'Delete an entry from the secrets store' - args << "Usage: nextflow secrets $name".toString() - args << '' - addOption('secretName', args) - args << '' + void usage(List result) { + result << 'Delete an entry from the secrets store' + result << "Usage: nextflow secrets $name".toString() + result << '' + addOption('secretName', result) + result << '' } } } diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdView.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdView.groovy index e0d637ab8d..ee93b42317 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdView.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdView.groovy @@ -33,17 +33,19 @@ import nextflow.scm.AssetManager @CompileStatic class CmdView { + static final public NAME = 'view' + interface Options { String getPipeline() boolean getQuiet() boolean getAll() } - @Parameters(commandDescription = 'View project script file(s)') + @Parameters(commandDescription = "View project script file(s)") static class V1 extends CmdBase implements Options { @Override - String getName() { 'view' } + String getName() { NAME } @Parameter(description = 'project name', required = true) List args = [] diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/HubOptions.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/HubOptions.groovy index 628e2d7d72..9279fcfa6d 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/HubOptions.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/HubOptions.groovy @@ -20,17 +20,59 @@ import com.beust.jcommander.Parameter import groovy.transform.CompileStatic /** * Defines the command line parameters for command that need to interact with a pipeline service hub i.e. GitHub or BitBucket - * - * @author Paolo Di Tommaso - */ + * + * @author Paolo Di Tommaso + */ @CompileStatic -trait HubOptions implements IHubOptions { +trait HubOptions { + + abstract String getHubProvider() + + abstract String getHubUserCli() + + abstract void setHubProvider(String hub) + + static trait V1 implements HubOptions { + + @Parameter(names=['-hub'], description = "Service hub where the project is hosted") + String hubProvider + + @Parameter(names='-user', description = 'Private repository user name') + String hubUserCli + + } + + /** + * Return the password provided on the command line or stop allowing the user to enter it on the console + * + * @return The password entered or {@code null} if no user has been entered + */ + String getHubPassword() { + + if( !hubUserCli ) + return null + + def p = hubUserCli.indexOf(':') + if( p != -1 ) + return hubUserCli.substring(p+1) + + def console = System.console() + if( !console ) + return null + + print "Enter your $hubProvider password: " + char[] pwd = console.readPassword() + new String(pwd) + } - @Parameter(names=['-hub'], description = "Service hub where the project is hosted") - String hubProvider + String getHubUser() { + if( !hubUserCli ) { + return hubUserCli + } - @Parameter(names='-user', description = 'Private repository user name') - String hubUserCli + def p = hubUserCli.indexOf(':') + return p != -1 ? hubUserCli.substring(0,p) : hubUserCli + } } diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/IHubOptions.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/IHubOptions.groovy deleted file mode 100644 index c11cd85996..0000000000 --- a/modules/nextflow/src/main/groovy/nextflow/cli/IHubOptions.groovy +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2013-2023, Seqera Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package nextflow.cli - -import groovy.transform.CompileStatic - -/** - * Defines the command line options for interacting with - * a git registry (GitHub, BitBucket, etc) - * - * @author Paolo Di Tommaso - */ -@CompileStatic -trait IHubOptions { - - abstract String getHubProvider() - - abstract String getHubUserCli() - - abstract void setHubProvider(String hub) - - /** - * Return the password provided on the command line or stop allowing the user to enter it on the console - * - * @return The password entered or {@code null} if no user has been entered - */ - String getHubPassword() { - - if( !hubUserCli ) - return null - - def p = hubUserCli.indexOf(':') - if( p != -1 ) - return hubUserCli.substring(p+1) - - def console = System.console() - if( !console ) - return null - - print "Enter your $hubProvider password: " - char[] pwd = console.readPassword() - new String(pwd) - } - - String getHubUser() { - if( !hubUserCli ) { - return null - } - - def p = hubUserCli.indexOf(':') - return p != -1 ? hubUserCli.substring(0,p) : hubUserCli - } - -} diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/ILauncherOptions.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/ILauncherOptions.groovy deleted file mode 100644 index d56fb04f6a..0000000000 --- a/modules/nextflow/src/main/groovy/nextflow/cli/ILauncherOptions.groovy +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2020-2022, Seqera Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package nextflow.cli - -import groovy.util.logging.Slf4j -import nextflow.exception.AbortOperationException -import org.fusesource.jansi.Ansi - -/** - * Interface for top-level CLI options. - * - * @author Paolo Di Tommaso - */ -@Slf4j -trait ILauncherOptions { - - abstract Boolean getAnsiLogCli() - - abstract boolean isBackground() - - abstract List getConfig() - - abstract List getDebug() - - abstract boolean getIgnoreConfigIncludes() - - abstract String getLogFile() - - abstract boolean isQuiet() - - abstract String getSyslog() - - abstract List getTrace() - - abstract List getUserConfig() - - abstract void setAnsiLog(boolean value) - - abstract void setBackground(boolean value) - - boolean getAnsiLog() { - if( ansiLogCli && quiet ) - throw new AbortOperationException("Command line options `quiet` and `ansi-log` cannot be used together") - - if( ansiLogCli != null ) - return ansiLogCli - - if( background ) - return ansiLogCli = false - - if( quiet ) - return ansiLogCli = false - - final env = System.getenv('NXF_ANSI_LOG') - if( env ) try { - return Boolean.parseBoolean(env) - } - catch (Exception e) { - log.warn "Invalid boolean value for variable NXF_ANSI_LOG: $env -- it must be 'true' or 'false'" - } - return Ansi.isEnabled() - } - - boolean hasAnsiLogFlag() { - ansiLogCli==true || System.getenv('NXF_ANSI_LOG')=='true' - } - -} diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/Launcher.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/Launcher.groovy index bdc04c6bbf..f40ad887cc 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/Launcher.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/Launcher.groovy @@ -52,7 +52,7 @@ class Launcher { private JCommander jcommander - private LauncherOptions options + private CliOptions.V1 options private CmdBase command @@ -98,14 +98,14 @@ class Launcher { ] if( SecretsLoader.isEnabled() ) - allCommands.add(new CmdSecrets.V1()) + allCommands.add(new CmdSecret.V1()) // legacy command final cmdCloud = SpuriousDeps.cmdCloud() if( cmdCloud ) allCommands.add(cmdCloud) - options = new LauncherOptions() + options = new CliOptions.V1() jcommander = new JCommander(options) allCommands.each { cmd -> cmd.launcher = this; @@ -175,7 +175,7 @@ class Launcher { } } - LauncherOptions getOptions() { options } + CliOptions.V1 getOptions() { options } List getNormalizedArgs() { normalizedArgs } @@ -362,7 +362,7 @@ class Launcher { } println "Usage: nextflow [options] COMMAND [arg...]\n" - printOptions(LauncherOptions) + printOptions(CliOptions.V1) printCommands(allCommands) } diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/LauncherOptions.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/LauncherOptions.groovy deleted file mode 100644 index 7d14c7ad1f..0000000000 --- a/modules/nextflow/src/main/groovy/nextflow/cli/LauncherOptions.groovy +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2020-2022, Seqera Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package nextflow.cli - -import com.beust.jcommander.DynamicParameter -import com.beust.jcommander.Parameter -import groovy.transform.CompileStatic -import nextflow.cli.ILauncherOptions - -/** - * Top-level CLI (v1) options - * - * @author Paolo Di Tommaso - */ -@CompileStatic -class LauncherOptions implements ILauncherOptions { - - Boolean ansiLogCli - - void setAnsiLog(boolean value) { ansiLogCli = value } - - @Parameter(names = ['-bg'], arity = 0, description = 'Execute nextflow in background') - boolean background - - @Parameter(names = ['-C'], description = 'Use the specified configuration file(s) overriding any defaults') - List config - - @Parameter(names = ['-c','-config'], description = 'Add the specified file to configuration set') - List userConfig - - @Parameter(names = ['-config-ignore-includes'], description = 'Disable the parsing of config includes') - boolean ignoreConfigIncludes - - @DynamicParameter(names = ['-D'], description = 'Set JVM properties' ) - Map jvmOpts = [:] - - @Parameter(names = ['-debug'], hidden = true) - List debug - - @Parameter(names = ['-d','-dockerize'], arity = 0, description = 'Launch nextflow via Docker (experimental)') - boolean dockerize - - @Parameter(names = ['-h'], description = 'Print this help', help = true) - boolean help - - @Parameter(names = ['-log'], description = 'Set nextflow log file path') - String logFile - - @Parameter(names = ['-q','-quiet'], description = 'Do not print information messages' ) - boolean quiet - - @Parameter(names = ['-self-update'], arity = 0, description = 'Update nextflow to the latest version', hidden = true) - boolean selfUpdate - - @Parameter(names = ['-syslog'], description = 'Send logs to syslog server (eg. localhost:514)' ) - String syslog - - @Parameter(names = ['-trace'], description = 'Enable trace level logging for the specified package name - multiple packages can be provided separating them with a comma e.g. \'-trace nextflow,io.seqera\'') - List trace - - @Parameter(names = ['-v'], description = 'Print the program version') - boolean version - - @Parameter(names = ['-version'], description = 'Print the program version (full)') - boolean fullVersion - -} diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/PluginAbstractExec.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/PluginAbstractExec.groovy index ff45ab3829..de7858704d 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/PluginAbstractExec.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/PluginAbstractExec.groovy @@ -44,7 +44,7 @@ trait PluginAbstractExec implements PluginExecAware { abstract List getCommands() @Override - final int exec(ILauncherOptions options, String pluginId, String cmd, List args) { + final int exec(CliOptions options, String pluginId, String cmd, List args) { // create the config final config = new ConfigBuilder() .setLauncherOptions(options) diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/PluginExecAware.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/PluginExecAware.groovy index d15d772d07..9c9f4b89d8 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/PluginExecAware.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/PluginExecAware.groovy @@ -26,6 +26,6 @@ interface PluginExecAware { static final String CMD_SEP = ':' - int exec(ILauncherOptions options, String pluginId, String cmd, List args) + int exec(CliOptions options, String pluginId, String cmd, List args) } diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/v2/CleanCmd.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/v2/CleanCmd.groovy index 616616054b..49dcfe98bd 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/v2/CleanCmd.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/v2/CleanCmd.groovy @@ -18,7 +18,7 @@ package nextflow.cli.v2 import groovy.transform.CompileStatic import nextflow.cli.CmdClean -import nextflow.cli.ILauncherOptions +import nextflow.cli.CliOptions import picocli.CommandLine.Command import picocli.CommandLine.Option import picocli.CommandLine.Parameters @@ -64,7 +64,7 @@ class CleanCmd extends AbstractCmd implements CmdClean.Options { List args = [] @Override - ILauncherOptions getLauncherOptions() { + CliOptions getLauncherOptions() { launcher.options } diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/v2/LauncherOptions.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/v2/CliOptionsV2.groovy similarity index 96% rename from modules/nextflow/src/main/groovy/nextflow/cli/v2/LauncherOptions.groovy rename to modules/nextflow/src/main/groovy/nextflow/cli/v2/CliOptionsV2.groovy index 3035ee73f8..01c60b247f 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/v2/LauncherOptions.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/v2/CliOptionsV2.groovy @@ -17,7 +17,7 @@ package nextflow.cli.v2 import groovy.transform.CompileStatic -import nextflow.cli.ILauncherOptions +import nextflow.cli.CliOptions import picocli.CommandLine.Option /** @@ -26,7 +26,7 @@ import picocli.CommandLine.Option * @author Ben Sherman */ @CompileStatic -class LauncherOptions implements ILauncherOptions { +class CliOptionsV2 implements CliOptions { Boolean ansiLogCli diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/v2/CloneCmd.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/v2/CloneCmd.groovy index 2e2e38b639..a04cf8eef4 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/v2/CloneCmd.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/v2/CloneCmd.groovy @@ -32,7 +32,7 @@ import picocli.CommandLine.Parameters name = 'clone', description = 'Clone a project into a folder' ) -class CloneCmd extends AbstractCmd implements CmdClone.Options, HubOptions { +class CloneCmd extends AbstractCmd implements CmdClone.Options, HubOptionsV2 { @Parameters(index = '0', description = 'name of the project to clone') String pipeline diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/v2/ConfigCmd.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/v2/ConfigCmd.groovy index 68ebbc572b..7652ad9bcb 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/v2/ConfigCmd.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/v2/ConfigCmd.groovy @@ -18,7 +18,7 @@ package nextflow.cli.v2 import groovy.transform.CompileStatic import nextflow.cli.CmdConfig -import nextflow.cli.ILauncherOptions +import nextflow.cli.CliOptions import picocli.CommandLine.Command import picocli.CommandLine.Option import picocli.CommandLine.Parameters @@ -58,7 +58,7 @@ class ConfigCmd extends AbstractCmd implements CmdConfig.Options { boolean sort @Override - ILauncherOptions getLauncherOptions() { + CliOptions getLauncherOptions() { launcher.options } diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/v2/HubOptions.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/v2/HubOptionsV2.groovy similarity index 93% rename from modules/nextflow/src/main/groovy/nextflow/cli/v2/HubOptions.groovy rename to modules/nextflow/src/main/groovy/nextflow/cli/v2/HubOptionsV2.groovy index 2253cf37cd..da196e95d4 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/v2/HubOptions.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/v2/HubOptionsV2.groovy @@ -17,7 +17,7 @@ package nextflow.cli.v2 import groovy.transform.CompileStatic -import nextflow.cli.IHubOptions +import nextflow.cli.HubOptions import picocli.CommandLine.Option /** @@ -27,7 +27,7 @@ import picocli.CommandLine.Option * @author Ben Sherman */ @CompileStatic -trait HubOptions implements IHubOptions { +trait HubOptionsV2 implements HubOptions { @Option(names = ['--hub'], paramLabel = '', description = 'Service hub where the project is hosted') String hubProvider diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/v2/Launcher.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/v2/Launcher.groovy index a495c153dc..382a6f8162 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/v2/Launcher.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/v2/Launcher.groovy @@ -19,7 +19,7 @@ package nextflow.cli.v2 import groovy.transform.CompileStatic import groovy.util.logging.Slf4j import nextflow.Const -import nextflow.cli.ILauncherOptions +import nextflow.cli.CliOptions import nextflow.exception.AbortOperationException import nextflow.exception.AbortRunException import nextflow.exception.ConfigParseException @@ -71,14 +71,14 @@ import picocli.CommandLine.ParseResult class Launcher extends AbstractCmd { @ArgGroup(validate = false) - private LauncherOptions options + private CliOptionsV2 options private String cliString private boolean daemonMode Launcher() { - this.options = new LauncherOptions() + this.options = new CliOptionsV2() } private int executionStrategy(ParseResult parseResult) { @@ -130,7 +130,7 @@ class Launcher extends AbstractCmd { return cli } - LauncherOptions getOptions() { options } + CliOptionsV2 getOptions() { options } String getCliString() { cliString } diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/v2/NodeCmd.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/v2/NodeCmd.groovy index 08c503d5e5..e9a1844f55 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/v2/NodeCmd.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/v2/NodeCmd.groovy @@ -17,7 +17,7 @@ package nextflow.cli.v2 import groovy.transform.CompileStatic -import nextflow.cli.ILauncherOptions +import nextflow.cli.CliOptions import nextflow.cli.CmdNode import picocli.CommandLine.Command import picocli.CommandLine.Option @@ -51,7 +51,7 @@ class NodeCmd extends AbstractCmd implements CmdNode.Options { String provider @Override - ILauncherOptions getLauncherOptions() { + CliOptions getLauncherOptions() { launcher.options } diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/v2/PluginCmd.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/v2/PluginCmd.groovy index de380ea9bb..657390d4d9 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/v2/PluginCmd.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/v2/PluginCmd.groovy @@ -18,7 +18,7 @@ package nextflow.cli.v2 import groovy.transform.CompileStatic -import nextflow.cli.ILauncherOptions +import nextflow.cli.CliOptions import nextflow.cli.CmdPlugin import nextflow.exception.AbortOperationException import picocli.CommandLine.Command diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/v2/PullCmd.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/v2/PullCmd.groovy index 14c72294b9..0f35939dce 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/v2/PullCmd.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/v2/PullCmd.groovy @@ -32,7 +32,7 @@ import picocli.CommandLine.Parameters name = 'pull', description = 'Download or update a project' ) -class PullCmd extends AbstractCmd implements CmdPull.Options, HubOptions { +class PullCmd extends AbstractCmd implements CmdPull.Options, HubOptionsV2 { @Parameters(description = 'project name or repository url to pull') String pipeline diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/v2/RunCmd.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/v2/RunCmd.groovy index 3777561bdd..2e80962bac 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/v2/RunCmd.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/v2/RunCmd.groovy @@ -18,7 +18,7 @@ package nextflow.cli.v2 import groovy.transform.CompileStatic import groovy.util.logging.Slf4j -import nextflow.cli.ILauncherOptions +import nextflow.cli.CliOptions import nextflow.cli.CmdRun import nextflow.util.Duration import picocli.CommandLine.Command @@ -38,7 +38,7 @@ import picocli.CommandLine.ParentCommand name = 'run', description = 'Execute a pipeline' ) -class RunCmd extends AbstractCmd implements CmdRun.Options, HubOptions { +class RunCmd extends AbstractCmd implements CmdRun.Options, HubOptionsV2 { static class DurationConverter implements ITypeConverter { @Override @@ -246,6 +246,10 @@ class RunCmd extends AbstractCmd implements CmdRun.Options, HubOptions { int i = args.findIndexOf { it.startsWith('--') } pipelineArgs = i == -1 ? args : args[0..> accessToken pipeline >> 'nextflow-io/hello' targetName >> dir.toFile().toString() } - def cmd = new CloneImpl(options) + def cmd = new CmdClone(options) when: cmd.run() diff --git a/modules/nextflow/src/test/groovy/nextflow/cli/ConfigImplTest.groovy b/modules/nextflow/src/test/groovy/nextflow/cli/ConfigImplTest.groovy index 545108805d..17f35cc156 100644 --- a/modules/nextflow/src/test/groovy/nextflow/cli/ConfigImplTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/cli/ConfigImplTest.groovy @@ -18,8 +18,8 @@ package nextflow.cli import java.nio.file.Files -import nextflow.cli.v1.Launcher -import nextflow.cli.v1.LauncherOptions +import nextflow.cli.Launcher +import nextflow.cli.CliOptions import nextflow.plugin.Plugins import spock.lang.IgnoreIf import spock.lang.Specification @@ -42,7 +42,7 @@ class ConfigImplTest extends Specification { config.docker.enabled = true final buffer = new ByteArrayOutputStream() - def cmd = new ConfigImpl() + def cmd = new CmdConfig() when: cmd.printDefault0(config, buffer) @@ -71,8 +71,8 @@ class ConfigImplTest extends Specification { config.process.omega = "Hi' there" final buffer = new ByteArrayOutputStream() - def options = Mock(ConfigImpl.Options) { sort >> true } - def cmd = new ConfigImpl(options) + def options = Mock(CmdConfig.Options) { sort >> true } + def cmd = new CmdConfig(options) when: cmd.printProperties0(config, buffer) @@ -94,7 +94,7 @@ class ConfigImplTest extends Specification { given: ByteArrayOutputStream buffer ConfigObject config - def cmd = new ConfigImpl( Mock(ConfigImpl.Options) ) + def cmd = new CmdConfig( Mock(CmdConfig.Options) ) when: buffer = new ByteArrayOutputStream() @@ -139,7 +139,7 @@ class ConfigImplTest extends Specification { given: ByteArrayOutputStream buffer ConfigObject config - def cmd = new ConfigImpl( Mock(ConfigImpl.Options) ) + def cmd = new CmdConfig( Mock(CmdConfig.Options) ) when: buffer = new ByteArrayOutputStream() @@ -190,11 +190,11 @@ class ConfigImplTest extends Specification { ''' def buffer = new ByteArrayOutputStream() // command definition - def options = Mock(ConfigImpl.Options) { - launcherOptions >> new LauncherOptions(config: [CONFIG.toString()]) + def options = Mock(CmdConfig.Options) { + launcherOptions >> new CliOptions.V1(config: [CONFIG.toString()]) pipeline >> '.' } - def cmd = new ConfigImpl(options: options, stdout: buffer) + def cmd = new CmdConfig(options: options, stdout: buffer) when: cmd.run() @@ -242,11 +242,11 @@ class ConfigImplTest extends Specification { def buffer = new ByteArrayOutputStream() // command definition - def options = Mock(ConfigImpl.Options) { - launcherOptions >> new LauncherOptions(config: [CONFIG.toString()]) + def options = Mock(CmdConfig.Options) { + launcherOptions >> new CliOptions.V1(config: [CONFIG.toString()]) pipeline >> '.' } - def cmd = new ConfigImpl(options: options, stdout: buffer) + def cmd = new CmdConfig(options: options, stdout: buffer) when: cmd.run() @@ -283,12 +283,12 @@ class ConfigImplTest extends Specification { def 'should resolve remote config' () { given: def buffer = new ByteArrayOutputStream() - def options = Mock(ConfigImpl.Options) { + def options = Mock(CmdConfig.Options) { pipeline >> 'https://github.com/nextflow-io/hello' showAllProfiles >> true - launcherOptions >> Mock(LauncherOptions) + launcherOptions >> Mock(CliOptions.V1) } - def cmd = new ConfigImpl(options: options, stdout: buffer) + def cmd = new CmdConfig(options: options, stdout: buffer) when: cmd.run() @@ -328,12 +328,12 @@ class ConfigImplTest extends Specification { def buffer = new ByteArrayOutputStream() // command definition - def options = Mock(ConfigImpl.Options) { + def options = Mock(CmdConfig.Options) { showAllProfiles >> true - launcherOptions >> new LauncherOptions(config: [CONFIG.toString()]) + launcherOptions >> new CliOptions.V1(config: [CONFIG.toString()]) pipeline >> '.' } - def cmd = new ConfigImpl(options: options, stdout: buffer) + def cmd = new CmdConfig(options: options, stdout: buffer) when: cmd.run() diff --git a/modules/nextflow/src/test/groovy/nextflow/cli/HubOptionsTest.groovy b/modules/nextflow/src/test/groovy/nextflow/cli/HubOptionsTest.groovy index dc6eedb21e..3baa1d5e65 100644 --- a/modules/nextflow/src/test/groovy/nextflow/cli/HubOptionsTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/cli/HubOptionsTest.groovy @@ -1,6 +1,5 @@ /* * Copyright 2020-2022, Seqera Labs - * Copyright 2013-2019, Centre for Genomic Regulation (CRG) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +27,7 @@ class HubOptionsTest extends Specification { def testUserV1() { when: - def cmd = [:] as v1.HubOptions + def cmd = [:] as HubOptions.V1 cmd.hubUserCli = credential then: cmd.getHubUser() == user @@ -45,7 +44,7 @@ class HubOptionsTest extends Specification { def testUserV2() { when: - def cmd = [:] as v2.HubOptions + def cmd = [:] as HubOptions.V2 cmd.hubUserCli = credential then: cmd.getHubUser() == user diff --git a/modules/nextflow/src/test/groovy/nextflow/cli/InfoImplTest.groovy b/modules/nextflow/src/test/groovy/nextflow/cli/InfoImplTest.groovy index 93a8ef353d..26abfddd76 100644 --- a/modules/nextflow/src/test/groovy/nextflow/cli/InfoImplTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/cli/InfoImplTest.groovy @@ -58,8 +58,8 @@ class InfoImplTest extends Specification { when: def buffer = new ByteArrayOutputStream() def screen = buffer.toString() - def options = Mock(InfoImpl.Options) { pipeline >> 'hello' } - def cmd = new InfoImpl(options: options, out: new PrintStream(buffer)) + def options = Mock(CmdInfo.Options) { pipeline >> 'hello' } + def cmd = new CmdInfo(options: options, out: new PrintStream(buffer)) cmd.run() @@ -78,8 +78,8 @@ class InfoImplTest extends Specification { def buffer = new ByteArrayOutputStream() def screen = buffer.toString() def json = (Map)new JsonSlurper().parseText(screen) - def options = Mock(InfoImpl.Options) { pipeline >> 'hello' ; format >> 'json' } - def cmd = new InfoImpl(options: options, out: new PrintStream(buffer)) + def options = Mock(CmdInfo.Options) { pipeline >> 'hello' ; format >> 'json' } + def cmd = new CmdInfo(options: options, out: new PrintStream(buffer)) cmd.run() @@ -104,8 +104,8 @@ class InfoImplTest extends Specification { def buffer = new ByteArrayOutputStream() def screen = buffer.toString() def json = (Map)new Yaml().load(screen) - def options = Mock(InfoImpl.Options) { pipeline >> 'hello' ; format >> 'yaml' } - def cmd = new InfoImpl(options: options, out: new PrintStream(buffer)) + def options = Mock(CmdInfo.Options) { pipeline >> 'hello' ; format >> 'yaml' } + def cmd = new CmdInfo(options: options, out: new PrintStream(buffer)) cmd.run() diff --git a/modules/nextflow/src/test/groovy/nextflow/cli/LogImplTest.groovy b/modules/nextflow/src/test/groovy/nextflow/cli/LogImplTest.groovy index 7d464178cc..c0a2f08b79 100644 --- a/modules/nextflow/src/test/groovy/nextflow/cli/LogImplTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/cli/LogImplTest.groovy @@ -101,10 +101,10 @@ class LogImplTest extends Specification { history.write(runName,uuid,'b3d3aca8eb','run') when: - def options = Mock(LogImpl.Options) { + def options = Mock(CmdLog.Options) { args >> [runName] } - def log = new LogImpl(basePath: folder, options: options) + def log = new CmdLog(basePath: folder, options: options) log.run() def stdout = capture .toString() @@ -174,11 +174,11 @@ class LogImplTest extends Specification { history.write(runName,uuid,'b3d3aca8eb','run') when: - def options = Mock(LogImpl.Options) { + def options = Mock(CmdLog.Options) { filterStr >> 'exit == 0' args >> ['test_1'] } - def log = new LogImpl(basePath: folder, options: options) + def log = new CmdLog(basePath: folder, options: options) log.run() def stdout = capture diff --git a/modules/nextflow/src/test/groovy/nextflow/cli/PullImplTest.groovy b/modules/nextflow/src/test/groovy/nextflow/cli/PullImplTest.groovy index f4b87060f8..b9b6253b7c 100644 --- a/modules/nextflow/src/test/groovy/nextflow/cli/PullImplTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/cli/PullImplTest.groovy @@ -39,11 +39,11 @@ class PullImplTest extends Specification { given: def accessToken = System.getenv('NXF_GITHUB_ACCESS_TOKEN') def dir = Files.createTempDirectory('test') - def options = Mock(PullImpl.Options) { + def options = Mock(CmdPull.Options) { pipeline >> 'nextflow-io/hello' hubUser >> accessToken } - def cmd = new PullImpl(options: options, root: dir.toFile()) + def cmd = new CmdPull(options: options, root: dir.toFile()) when: cmd.run() diff --git a/modules/nextflow/src/test/groovy/nextflow/cli/RunImplTest.groovy b/modules/nextflow/src/test/groovy/nextflow/cli/RunImplTest.groovy index 145c772ff8..a46ba897ca 100644 --- a/modules/nextflow/src/test/groovy/nextflow/cli/RunImplTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/cli/RunImplTest.groovy @@ -39,7 +39,7 @@ class RunImplTest extends Specification { def 'should parse cmd param=#STR' () { expect: - RunImpl.parseParamValue(STR) == EXPECTED + CmdRun.parseParamValue(STR) == EXPECTED where: STR | EXPECTED @@ -65,9 +65,9 @@ class RunImplTest extends Specification { SysEnv.push(NXF_DISABLE_PARAMS_TYPE_DETECTION: 'true') expect: - RunImpl.parseParamValue('true') == 'true' - RunImpl.parseParamValue('1000') == '1000' - RunImpl.parseParamValue('hola') == 'hola' + CmdRun.parseParamValue('true') == 'true' + CmdRun.parseParamValue('1000') == '1000' + CmdRun.parseParamValue('hola') == 'hola' cleanup: SysEnv.pop() @@ -75,7 +75,7 @@ class RunImplTest extends Specification { def 'should parse nested params' () { when: - RunImpl.addParam(PARAMS, KEY, VALUE) + CmdRun.addParam(PARAMS, KEY, VALUE) then: PARAMS == EXPECTED @@ -93,7 +93,7 @@ class RunImplTest extends Specification { @Unroll def 'should check run name #STR' () { expect: - RunImpl.matchRunName(STR) == EXPECTED + CmdRun.matchRunName(STR) == EXPECTED where: EXPECTED | STR true | 'foo' @@ -133,7 +133,7 @@ class RunImplTest extends Specification { def file = folder.resolve('params.json') file.text = JSON and: - def cmd = new RunImpl( Mock(RunImpl.Options) { paramsFile >> file.toString() } ) + def cmd = new CmdRun( Mock(CmdRun.Options) { paramsFile >> file.toString() } ) def params = cmd.parsedParams() then: params.abc == 1 @@ -145,7 +145,7 @@ class RunImplTest extends Specification { file = folder.resolve('params.yaml') file.text = YAML and: - cmd = new RunImpl( Mock(RunImpl.Options) { paramsFile >> file.toString() } ) + cmd = new CmdRun( Mock(CmdRun.Options) { paramsFile >> file.toString() } ) params = cmd.parsedParams() then: params.foo == 1 @@ -154,7 +154,7 @@ class RunImplTest extends Specification { cmd.hasParams() when: - cmd = new RunImpl(options: Mock(RunImpl.Options), sysEnv: [NXF_PARAMS_FILE: file.toString()]) + cmd = new CmdRun(options: Mock(CmdRun.Options), sysEnv: [NXF_PARAMS_FILE: file.toString()]) params = cmd.parsedParams() then: params.foo == 1 @@ -163,7 +163,7 @@ class RunImplTest extends Specification { cmd.hasParams() when: - cmd = new RunImpl(options: Mock(RunImpl.Options), sysEnv: [NXF_PARAMS_FILE: '/missing/path.yml']) + cmd = new CmdRun(options: Mock(CmdRun.Options), sysEnv: [NXF_PARAMS_FILE: '/missing/path.yml']) cmd.parsedParams() then: def e = thrown(AbortOperationException) @@ -186,7 +186,7 @@ class RunImplTest extends Specification { } '''.stripIndent() when: - def cmd = new RunImpl( Mock(RunImpl.Options) { paramsFile >> json.toString() } ) + def cmd = new CmdRun( Mock(CmdRun.Options) { paramsFile >> json.toString() } ) and: def result = cmd.parsedParams( [baseDir: '/BASE/DIR', launchDir: '/WORK/DIR'] ) then: @@ -212,7 +212,7 @@ class RunImplTest extends Specification { omega: "${baseDir}/end" '''.stripIndent() when: - def cmd = new RunImpl( Mock(RunImpl.Options) { paramsFile >> json.toString() } ) + def cmd = new CmdRun( Mock(CmdRun.Options) { paramsFile >> json.toString() } ) and: def result = cmd.parsedParams( [baseDir: '/BASE/DIR', launchDir: '/WORK/DIR'] ) then: @@ -229,34 +229,34 @@ class RunImplTest extends Specification { def options when: - options = Mock(RunImpl.Options) + options = Mock(CmdRun.Options) then: - !new RunImpl(options).hasParams() + !new CmdRun(options).hasParams() when: - options = Mock(RunImpl.Options) { params >> [foo:'x'] } + options = Mock(CmdRun.Options) { params >> [foo:'x'] } then: - new RunImpl(options).hasParams() + new CmdRun(options).hasParams() when: - options = Mock(RunImpl.Options) { paramsFile >> '/some/file.yml' } + options = Mock(CmdRun.Options) { paramsFile >> '/some/file.yml' } then: - new RunImpl(options).hasParams() + new CmdRun(options).hasParams() when: - options = Mock(RunImpl.Options) + options = Mock(CmdRun.Options) then: - new RunImpl(options: options, sysEnv: [NXF_PARAMS_FILE: '/some/file.yml']).hasParams() + new CmdRun(options: options, sysEnv: [NXF_PARAMS_FILE: '/some/file.yml']).hasParams() } def 'should replace values' () { expect: // only dollar are ignored - new RunImpl( Mock(RunImpl.Options) ).replaceVars0('some $xxx there', [xxx:'here']) == 'some $xxx there' + new CmdRun( Mock(CmdRun.Options) ).replaceVars0('some $xxx there', [xxx:'here']) == 'some $xxx there' and: // dollar wrapped with {} are interpreted as vars - new RunImpl( Mock(RunImpl.Options) ).replaceVars0('some ${xxx} ${xxx}', [xxx:'here']) == 'some here here' + new CmdRun( Mock(CmdRun.Options) ).replaceVars0('some ${xxx} ${xxx}', [xxx:'here']) == 'some here here' and: def text = '''\ @@ -266,7 +266,7 @@ class RunImplTest extends Specification { omega: "${unknown}" '''.stripIndent() - new RunImpl( Mock(RunImpl.Options) ).replaceVars0(text, [baseDir:'/HOME', launchDir: '/WORK' ] ) == '''\ + new CmdRun( Mock(CmdRun.Options) ).replaceVars0(text, [baseDir:'/HOME', launchDir: '/WORK' ] ) == '''\ alpha: "/HOME/hello" delta: "/WORK/world" gamma: "${012345}" @@ -276,17 +276,17 @@ class RunImplTest extends Specification { def 'should validate dont kill jobs' () { when: - def cmd = new RunImpl( Mock(RunImpl.Options) ) + def cmd = new CmdRun( Mock(CmdRun.Options) ) then: cmd.getDisableJobsCancellation() == false when: - cmd = new RunImpl( Mock(RunImpl.Options) { disableJobsCancellation >> true } ) + cmd = new CmdRun( Mock(CmdRun.Options) { disableJobsCancellation >> true } ) then: cmd.getDisableJobsCancellation() == true when: - cmd = new RunImpl(options: Mock(RunImpl.Options), sysEnv: [NXF_DISABLE_JOBS_CANCELLATION: true]) + cmd = new CmdRun(options: Mock(CmdRun.Options), sysEnv: [NXF_DISABLE_JOBS_CANCELLATION: true]) then: cmd.getDisableJobsCancellation() == true } @@ -294,7 +294,7 @@ class RunImplTest extends Specification { @Unroll def 'should guss is repo' () { expect: - RunImpl.guessIsRepo(PATH) == EXPECTED + CmdRun.guessIsRepo(PATH) == EXPECTED where: EXPECTED | PATH @@ -326,47 +326,47 @@ class RunImplTest extends Specification { expect: // default to DSL2 if nothing is specified - RunImpl.detectDslMode(new ConfigMap(), '', [:]) == '2' + CmdRun.detectDslMode(new ConfigMap(), '', [:]) == '2' and: // take from the config - RunImpl.detectDslMode(new ConfigMap([nextflow:[enable:[dsl:1]]]), '', [:]) == '1' + CmdRun.detectDslMode(new ConfigMap([nextflow:[enable:[dsl:1]]]), '', [:]) == '1' and: // the script declaration has priority - RunImpl.detectDslMode(new ConfigMap([nextflow:[enable:[dsl:1]]]), 'nextflow.enable.dsl=3', [:]) == '3' + CmdRun.detectDslMode(new ConfigMap([nextflow:[enable:[dsl:1]]]), 'nextflow.enable.dsl=3', [:]) == '3' and: // env variable is ignored when the config is provided - RunImpl.detectDslMode(new ConfigMap([nextflow:[enable:[dsl:1]]]), 'echo hello', [NXF_DEFAULT_DSL:'4']) == '1' + CmdRun.detectDslMode(new ConfigMap([nextflow:[enable:[dsl:1]]]), 'echo hello', [NXF_DEFAULT_DSL:'4']) == '1' and: // env variable is used if nothing else is specified - RunImpl.detectDslMode(new ConfigMap(), 'echo hello', [NXF_DEFAULT_DSL:'4']) == '4' + CmdRun.detectDslMode(new ConfigMap(), 'echo hello', [NXF_DEFAULT_DSL:'4']) == '4' and: // dsl mode is taken from the config - RunImpl.detectDslMode(new ConfigMap([nextflow:[enable:[dsl:4]]]), DSL1_SCRIPT, [:]) == '4' + CmdRun.detectDslMode(new ConfigMap([nextflow:[enable:[dsl:4]]]), DSL1_SCRIPT, [:]) == '4' and: // dsl mode is taken from the config - RunImpl.detectDslMode(new ConfigMap([nextflow:[enable:[dsl:4]]]), DSL2_SCRIPT, [:]) == '4' + CmdRun.detectDslMode(new ConfigMap([nextflow:[enable:[dsl:4]]]), DSL2_SCRIPT, [:]) == '4' and: // detect version from DSL1 script - RunImpl.detectDslMode(new ConfigMap(), DSL1_SCRIPT, [NXF_DEFAULT_DSL:'2']) == '1' + CmdRun.detectDslMode(new ConfigMap(), DSL1_SCRIPT, [NXF_DEFAULT_DSL:'2']) == '1' and: // detect version from DSL1 script - RunImpl.detectDslMode(new ConfigMap(), DSL1_SCRIPT, [:]) == '1' + CmdRun.detectDslMode(new ConfigMap(), DSL1_SCRIPT, [:]) == '1' and: // detect version from env - RunImpl.detectDslMode(new ConfigMap(), DSL2_SCRIPT, [NXF_DEFAULT_DSL:'2']) == '2' + CmdRun.detectDslMode(new ConfigMap(), DSL2_SCRIPT, [NXF_DEFAULT_DSL:'2']) == '2' and: // detect version from global default - RunImpl.detectDslMode(new ConfigMap(), DSL2_SCRIPT, [:]) == '2' + CmdRun.detectDslMode(new ConfigMap(), DSL2_SCRIPT, [:]) == '2' } def 'should warn for invalid config vars' () { @@ -374,7 +374,7 @@ class RunImplTest extends Specification { def ENV = [NXF_ANSI_SUMMARY: 'true'] when: - new RunImpl( Mock(RunImpl.Options) ).checkConfigEnv(new ConfigMap([env:ENV])) + new CmdRun( Mock(CmdRun.Options) ).checkConfigEnv(new ConfigMap([env:ENV])) then: def warning = capture @@ -391,7 +391,7 @@ class RunImplTest extends Specification { def ENV = [FOO: '/something', NXF_DEBUG: 'true'] when: - new RunImpl( Mock(RunImpl.Options) ).checkConfigEnv(new ConfigMap([env:ENV])) + new CmdRun( Mock(CmdRun.Options) ).checkConfigEnv(new ConfigMap([env:ENV])) then: def warning = capture diff --git a/modules/nextflow/src/test/groovy/nextflow/cli/v1/LauncherTest.groovy b/modules/nextflow/src/test/groovy/nextflow/cli/v1/LauncherTest.groovy index 4ba661fb34..322b597183 100644 --- a/modules/nextflow/src/test/groovy/nextflow/cli/v1/LauncherTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/cli/v1/LauncherTest.groovy @@ -14,7 +14,7 @@ * limitations under the License. */ -package nextflow.cli.v1 +package nextflow.cli import spock.lang.Specification @@ -57,13 +57,13 @@ class LauncherTest extends Specification { when: launcher = new Launcher().parseMainArgs('help') then: - launcher.command instanceof HelpCmd + launcher.command instanceof CmdHelp launcher.command.args == null when: launcher = new Launcher().parseMainArgs('help','xxx') then: - launcher.command instanceof HelpCmd + launcher.command instanceof CmdHelp launcher.command.args == ['xxx'] } @@ -119,7 +119,7 @@ class LauncherTest extends Specification { when: def launcher = new Launcher().parseMainArgs('run','xxx', '-hub', 'bitbucket', '-user','xx:yy') then: - launcher.command instanceof RunCmd + launcher.command instanceof CmdRun.V1 launcher.command.pipeline == 'xxx' launcher.command.hubProvider == 'bitbucket' launcher.command.hubUser == 'xx' @@ -128,14 +128,14 @@ class LauncherTest extends Specification { when: launcher = new Launcher().parseMainArgs('run','alpha', '-hub', 'github') then: - launcher.command instanceof RunCmd + launcher.command instanceof CmdRun.V1 launcher.command.pipeline == 'alpha' launcher.command.hubProvider == 'github' when: launcher = new Launcher().parseMainArgs('run', 'script.nf', 'arg1', 'arg2', '--alpha', '0', '--omega', '9') then: - launcher.command instanceof RunCmd + launcher.command instanceof CmdRun.V1 launcher.command.pipeline == 'script.nf' launcher.command.args == ['arg1', 'arg2'] launcher.command.params.'alpha' == '0' @@ -149,7 +149,7 @@ class LauncherTest extends Specification { given: def script = Files.createTempFile('file',null) def launcher = [:] as Launcher - launcher.allCommands = [ new RunCmd(), new InfoCmd() ] + launcher.allCommands = [ new CmdRun.V1(), new InfoCmd() ] expect: launcher.normalizeArgs('a','-bb','-ccc','dddd') == ['a','-bb','-ccc','dddd'] @@ -322,7 +322,7 @@ class LauncherTest extends Specification { given: def launcher = new Launcher() when: - launcher.printCommands( [new InfoCmd(), new RunCmd(), new ListCmd()] ) + launcher.printCommands( [new InfoCmd(), new CmdRun.V1(), new ListCmd()] ) then: capture.toString() == ''' Commands: diff --git a/modules/nextflow/src/test/groovy/nextflow/cli/v1/SecretsCmdTest.groovy b/modules/nextflow/src/test/groovy/nextflow/cli/v1/SecretsCmdTest.groovy index d1962314e5..c5736fb320 100644 --- a/modules/nextflow/src/test/groovy/nextflow/cli/v1/SecretsCmdTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/cli/v1/SecretsCmdTest.groovy @@ -14,7 +14,7 @@ * limitations under the License. */ -package nextflow.cli.v1 +package nextflow.cli import java.nio.file.Files import java.nio.file.Path diff --git a/modules/nextflow/src/test/groovy/nextflow/config/ConfigBuilderTest.groovy b/modules/nextflow/src/test/groovy/nextflow/config/ConfigBuilderTest.groovy index ab5029b688..f1b3c93c3b 100644 --- a/modules/nextflow/src/test/groovy/nextflow/config/ConfigBuilderTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/config/ConfigBuilderTest.groovy @@ -19,11 +19,11 @@ package nextflow.config import java.nio.file.Files import java.nio.file.Paths -import nextflow.cli.ConfigImpl -import nextflow.cli.NodeImpl -import nextflow.cli.RunImpl -import nextflow.cli.v1.Launcher -import nextflow.cli.v1.LauncherOptions +import nextflow.cli.CmdConfig +import nextflow.cli.CmdNode +import nextflow.cli.CmdRun +import nextflow.cli.Launcher +import nextflow.cli.CliOptions import nextflow.exception.AbortOperationException import nextflow.exception.ConfigParseException import nextflow.trace.TraceHelper @@ -177,8 +177,8 @@ class ConfigBuilderTest extends Specification { } ''' when: - def opt = new LauncherOptions() - def run = new RunImpl( Mock(RunImpl.Options) { params >> [alpha: 'Hello', beta: 'World', omega: 'Last'] }) + def opt = new CliOptions.V1() + def run = new CmdRun( Mock(CmdRun.Options) { params >> [alpha: 'Hello', beta: 'World', omega: 'Last'] }) def result = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).buildGivenFiles(file) then: @@ -210,8 +210,8 @@ class ConfigBuilderTest extends Specification { } ''' when: - def opt = new LauncherOptions() - def run = new RunImpl( Mock(RunImpl.Options) { params >> [alpha: 'Hello', beta: 'World', omega: 'Last'] }) + def opt = new CliOptions.V1() + def run = new CmdRun( Mock(CmdRun.Options) { params >> [alpha: 'Hello', beta: 'World', omega: 'Last'] }) def result = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).buildGivenFiles(file) then: @@ -262,8 +262,8 @@ class ConfigBuilderTest extends Specification { ''' when: - def opt = new LauncherOptions() - def run = new RunImpl( Mock(RunImpl.Options) { params >> [one: '1', two: 'dos', three: 'tres'] }) + def opt = new CliOptions.V1() + def run = new CmdRun( Mock(CmdRun.Options) { params >> [one: '1', two: 'dos', three: 'tres'] }) def config = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).buildGivenFiles(configMain.toPath()) then: @@ -308,8 +308,8 @@ class ConfigBuilderTest extends Specification { ''' when: - def opt = new LauncherOptions() - def run = new RunImpl( Mock(RunImpl.Options) { params >> [igenomes_base: 'test'] }) + def opt = new CliOptions.V1() + def run = new CmdRun( Mock(CmdRun.Options) { params >> [igenomes_base: 'test'] }) def config = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).buildGivenFiles(configMain.toPath()) then: @@ -400,8 +400,8 @@ class ConfigBuilderTest extends Specification { when: - def opt = new LauncherOptions() - def run = new RunImpl( Mock(RunImpl.Options) { params >> [alpha: 'AAA', beta: 'BBB'] }) + def opt = new CliOptions.V1() + def run = new CmdRun( Mock(CmdRun.Options) { params >> [alpha: 'AAA', beta: 'BBB'] }) def config = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).buildGivenFiles(file) then: config.params.alpha == 'AAA' @@ -413,8 +413,8 @@ class ConfigBuilderTest extends Specification { config.params.genomes.GRCh37.bowtie == '/data/genome' when: - opt = new LauncherOptions() - run = new RunImpl( Mock(RunImpl.Options) { params >> [alpha: 'AAA', beta: 'BBB'] ; profile >> 'first' }) + opt = new CliOptions.V1() + run = new CmdRun( Mock(CmdRun.Options) { params >> [alpha: 'AAA', beta: 'BBB'] ; profile >> 'first' }) config = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).buildGivenFiles(file) then: config.params.alpha == 'AAA' @@ -428,8 +428,8 @@ class ConfigBuilderTest extends Specification { when: - opt = new LauncherOptions() - run = new RunImpl( Mock(RunImpl.Options) { params >> [alpha: 'AAA', beta: 'BBB', genomes: 'xxx'] ; profile >> 'second' }) + opt = new CliOptions.V1() + run = new CmdRun( Mock(CmdRun.Options) { params >> [alpha: 'AAA', beta: 'BBB', genomes: 'xxx'] ; profile >> 'second' }) config = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).buildGivenFiles(file) then: config.params.alpha == 'AAA' @@ -472,8 +472,8 @@ class ConfigBuilderTest extends Specification { } ''' when: - def opt = new LauncherOptions() - def run = new RunImpl( Mock(RunImpl.Options) { paramsFile >> params }) + def opt = new CliOptions.V1() + def run = new CmdRun( Mock(CmdRun.Options) { paramsFile >> params }) def result = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).setBaseDir(baseDir).buildGivenFiles(file) then: @@ -514,8 +514,8 @@ class ConfigBuilderTest extends Specification { } ''' when: - def opt = new LauncherOptions() - def run = new RunImpl( Mock(RunImpl.Options) { getParamsFile() >> paramsFile ; params >> [alpha: 'Hola', beta: 'Mundo'] }) + def opt = new CliOptions.V1() + def run = new CmdRun( Mock(CmdRun.Options) { getParamsFile() >> paramsFile ; params >> [alpha: 'Hola', beta: 'Mundo'] }) def result = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).buildGivenFiles(file) then: @@ -601,8 +601,8 @@ class ConfigBuilderTest extends Specification { def 'command executor options'() { when: - def opt = new LauncherOptions() - def run = new RunImpl( Mock(RunImpl.Options) { executorOptions >> [ alpha: 1, 'beta.x': 'hola', 'beta.y': 'ciao' ] }) + def opt = new CliOptions.V1() + def run = new CmdRun( Mock(CmdRun.Options) { executorOptions >> [ alpha: 1, 'beta.x': 'hola', 'beta.y': 'ciao' ] }) def result = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).buildGivenFiles() then: result.executor.alpha == 1 @@ -614,8 +614,8 @@ class ConfigBuilderTest extends Specification { def 'run command cluster options'() { when: - def opt = new LauncherOptions() - def run = new RunImpl( Mock(RunImpl.Options) { clusterOptions >> [ alpha: 1, 'beta.x': 'hola', 'beta.y': 'ciao' ] }) + def opt = new CliOptions.V1() + def run = new CmdRun( Mock(CmdRun.Options) { clusterOptions >> [ alpha: 1, 'beta.x': 'hola', 'beta.y': 'ciao' ] }) def result = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).buildGivenFiles() then: result.cluster.alpha == 1 @@ -627,8 +627,8 @@ class ConfigBuilderTest extends Specification { def 'run with docker'() { when: - def opt = new LauncherOptions() - def run = new RunImpl( Mock(RunImpl.Options) { withDocker >> 'cbcrg/piper' }) + def opt = new CliOptions.V1() + def run = new CmdRun( Mock(CmdRun.Options) { withDocker >> 'cbcrg/piper' }) def config = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).build() then: @@ -651,8 +651,8 @@ class ConfigBuilderTest extends Specification { ''' when: - def opt = new LauncherOptions(config: [file.toFile().canonicalPath] ) - def run = new RunImpl( Mock(RunImpl.Options) { withDocker >> '-' }) + def opt = new CliOptions.V1(config: [file.toFile().canonicalPath] ) + def run = new CmdRun( Mock(CmdRun.Options) { withDocker >> '-' }) def config = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).build() then: config.docker.enabled @@ -660,8 +660,8 @@ class ConfigBuilderTest extends Specification { config.process.container == 'busybox' when: - opt = new LauncherOptions(config: [file.toFile().canonicalPath] ) - run = new RunImpl( Mock(RunImpl.Options) { withDocker >> 'cbcrg/mybox' }) + opt = new CliOptions.V1(config: [file.toFile().canonicalPath] ) + run = new CmdRun( Mock(CmdRun.Options) { withDocker >> 'cbcrg/mybox' }) config = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).build() then: config.docker.enabled @@ -679,8 +679,8 @@ class ConfigBuilderTest extends Specification { ''' process.$test.container = 'busybox' ''' - def opt = new LauncherOptions(config: [file.toFile().canonicalPath]) - def run = new RunImpl( Mock(RunImpl.Options) { withDocker >> '-' }) + def opt = new CliOptions.V1(config: [file.toFile().canonicalPath]) + def run = new CmdRun( Mock(CmdRun.Options) { withDocker >> '-' }) def config = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).build() then: config.docker.enabled @@ -691,16 +691,16 @@ class ConfigBuilderTest extends Specification { ''' process.container = 'busybox' ''' - opt = new LauncherOptions(config: [file.toFile().canonicalPath]) - run = new RunImpl( Mock(RunImpl.Options) { withDocker >> '-' }) + opt = new CliOptions.V1(config: [file.toFile().canonicalPath]) + run = new CmdRun( Mock(CmdRun.Options) { withDocker >> '-' }) config = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).build() then: config.docker.enabled config.process.container == 'busybox' when: - opt = new LauncherOptions() - run = new RunImpl( Mock(RunImpl.Options) { withDocker >> '-' }) + opt = new CliOptions.V1() + run = new CmdRun( Mock(CmdRun.Options) { withDocker >> '-' }) new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).build() then: def e = thrown(AbortOperationException) @@ -711,8 +711,8 @@ class ConfigBuilderTest extends Specification { ''' process.$test.tag = 'tag' ''' - opt = new LauncherOptions(config: [file.toFile().canonicalPath]) - run = new RunImpl( Mock(RunImpl.Options) { withDocker >> '-' }) + opt = new CliOptions.V1(config: [file.toFile().canonicalPath]) + run = new CmdRun( Mock(CmdRun.Options) { withDocker >> '-' }) new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).build() then: e = thrown(AbortOperationException) @@ -734,8 +734,8 @@ class ConfigBuilderTest extends Specification { ''' when: - def opt = new LauncherOptions(config: [file.toFile().canonicalPath] ) - def run = new RunImpl( Mock(RunImpl.Options) { withoutDocker >> true }) + def opt = new CliOptions.V1(config: [file.toFile().canonicalPath] ) + def run = new CmdRun( Mock(CmdRun.Options) { withoutDocker >> true }) def config = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).build() then: !config.docker.enabled @@ -747,9 +747,9 @@ class ConfigBuilderTest extends Specification { def 'config with cluster options'() { when: - def opt = new LauncherOptions() - def cmd = new NodeImpl( - Mock(NodeImpl.Options) { + def opt = new CliOptions.V1() + def cmd = new CmdNode( + Mock(CmdNode.Options) { clusterOptions >> [join: 'x', group: 'y', interface: 'abc', slots: 10, 'tcp.alpha':'uno', 'tcp.beta': 'due'] } ) @@ -792,7 +792,7 @@ class ConfigBuilderTest extends Specification { when: def config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: config.trace instanceof Map @@ -801,7 +801,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withTrace >> 'some-file' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withTrace >> 'some-file' })) then: config.trace instanceof Map config.trace.enabled @@ -810,7 +810,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() config.trace.file = 'foo.txt' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withTrace >> 'bar.txt' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withTrace >> 'bar.txt' })) then: // command line should override the config file config.trace instanceof Map config.trace.enabled @@ -819,7 +819,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() config.trace.file = 'foo.txt' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withTrace >> '-' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withTrace >> '-' })) then: // command line should override the config file config.trace instanceof Map config.trace.enabled @@ -827,7 +827,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withTrace >> '-' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withTrace >> '-' })) then: // command line should override the config file config.trace instanceof Map config.trace.enabled @@ -842,14 +842,14 @@ class ConfigBuilderTest extends Specification { when: def config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: !config.report when: config = new ConfigObject() config.report.file = 'foo.html' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: config.report instanceof Map !config.report.enabled @@ -857,7 +857,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withReport >> 'my-report.html' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withReport >> 'my-report.html' })) then: config.report instanceof Map config.report.enabled @@ -866,7 +866,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() config.report.file = 'this-report.html' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withReport >> 'my-report.html' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withReport >> 'my-report.html' })) then: config.report instanceof Map config.report.enabled @@ -875,7 +875,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() config.report.file = 'this-report.html' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withReport >> '-' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withReport >> '-' })) then: config.report instanceof Map config.report.enabled @@ -883,7 +883,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withReport >> '-' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withReport >> '-' })) then: config.report instanceof Map config.report.enabled @@ -899,14 +899,14 @@ class ConfigBuilderTest extends Specification { when: def config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: !config.dag when: config = new ConfigObject() config.dag.file = 'foo-dag.html' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: config.dag instanceof Map !config.dag.enabled @@ -914,7 +914,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withDag >> 'my-dag.html' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withDag >> 'my-dag.html' })) then: config.dag instanceof Map config.dag.enabled @@ -923,7 +923,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() config.dag.file = 'this-dag.html' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withDag >> 'my-dag.html' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withDag >> 'my-dag.html' })) then: config.dag instanceof Map config.dag.enabled @@ -932,7 +932,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() config.dag.file = 'this-dag.html' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withDag >> '-' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withDag >> '-' })) then: config.dag instanceof Map config.dag.enabled @@ -940,7 +940,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withDag >> '-' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withDag >> '-' })) then: config.dag instanceof Map config.dag.enabled @@ -955,14 +955,14 @@ class ConfigBuilderTest extends Specification { when: def config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: !config.weblog when: config = new ConfigObject() config.weblog.url = 'http://bar.com' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: config.weblog instanceof Map !config.weblog.enabled @@ -970,7 +970,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withWebLog >> 'http://foo.com' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withWebLog >> 'http://foo.com' })) then: config.weblog instanceof Map config.weblog.enabled @@ -980,7 +980,7 @@ class ConfigBuilderTest extends Specification { config = new ConfigObject() config.weblog.enabled = true config.weblog.url = 'http://bar.com' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withWebLog >> 'http://foo.com' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withWebLog >> 'http://foo.com' })) then: config.weblog instanceof Map config.weblog.enabled @@ -990,7 +990,7 @@ class ConfigBuilderTest extends Specification { config = new ConfigObject() config.weblog.enabled = true config.weblog.url = 'http://bar.com' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withWebLog >> '-' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withWebLog >> '-' })) then: config.weblog instanceof Map config.weblog.enabled @@ -999,7 +999,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() config.weblog.enabled = true - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withWebLog >> '-' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withWebLog >> '-' })) then: config.weblog instanceof Map config.weblog.enabled @@ -1015,14 +1015,14 @@ class ConfigBuilderTest extends Specification { when: def config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: !config.timeline when: config = new ConfigObject() config.timeline.file = 'my-file.html' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: config.timeline instanceof Map !config.timeline.enabled @@ -1030,7 +1030,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withTimeline >> 'my-timeline.html' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withTimeline >> 'my-timeline.html' })) then: config.timeline instanceof Map config.timeline.enabled @@ -1040,7 +1040,7 @@ class ConfigBuilderTest extends Specification { config = new ConfigObject() config.timeline.enabled = true config.timeline.file = 'this-timeline.html' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withTimeline >> 'my-timeline.html' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withTimeline >> 'my-timeline.html' })) then: config.timeline instanceof Map config.timeline.enabled @@ -1050,7 +1050,7 @@ class ConfigBuilderTest extends Specification { config = new ConfigObject() config.timeline.enabled = true config.timeline.file = 'my-timeline.html' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withTimeline >> '-' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withTimeline >> '-' })) then: config.timeline instanceof Map config.timeline.enabled @@ -1059,7 +1059,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() config.timeline.enabled = true - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withTimeline >> '-' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withTimeline >> '-' })) then: config.timeline instanceof Map config.timeline.enabled @@ -1074,14 +1074,14 @@ class ConfigBuilderTest extends Specification { when: def config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: !config.tower when: config = new ConfigObject() config.tower.endpoint = 'http://foo.com' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: config.tower instanceof Map !config.tower.enabled @@ -1089,7 +1089,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withTower >> 'http://bar.com' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withTower >> 'http://bar.com' })) then: config.tower instanceof Map config.tower.enabled @@ -1098,7 +1098,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() config.tower.endpoint = 'http://foo.com' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withTower >> '-' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withTower >> '-' })) then: config.tower instanceof Map config.tower.enabled @@ -1106,7 +1106,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withTower >> '-' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withTower >> '-' })) then: config.tower instanceof Map config.tower.enabled @@ -1121,14 +1121,14 @@ class ConfigBuilderTest extends Specification { when: def config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: !config.wave when: config = new ConfigObject() config.wave.endpoint = 'http://foo.com' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: config.wave instanceof Map !config.wave.enabled @@ -1136,7 +1136,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withWave >> 'http://bar.com' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withWave >> 'http://bar.com' })) then: config.wave instanceof Map config.wave.enabled @@ -1145,7 +1145,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() config.wave.endpoint = 'http://foo.com' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withWave >> '-' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withWave >> '-' })) then: config.wave instanceof Map config.wave.enabled @@ -1153,7 +1153,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withWave >> '-' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withWave >> '-' })) then: config.wave instanceof Map config.wave.enabled @@ -1168,14 +1168,14 @@ class ConfigBuilderTest extends Specification { when: def config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: !config.conda when: config = new ConfigObject() config.conda.createOptions = 'something' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: config.conda instanceof Map !config.conda.enabled @@ -1183,7 +1183,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withConda >> 'my-recipe.yml' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withConda >> 'my-recipe.yml' })) then: config.conda instanceof Map config.conda.enabled @@ -1192,7 +1192,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() config.conda.enabled = true - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withConda >> 'my-recipe.yml' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withConda >> 'my-recipe.yml' })) then: config.conda instanceof Map config.conda.enabled @@ -1201,7 +1201,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() config.process.conda = 'my-recipe.yml' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withConda >> '-' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withConda >> '-' })) then: config.conda instanceof Map config.conda.enabled @@ -1220,8 +1220,8 @@ class ConfigBuilderTest extends Specification { ''' when: - def opt = new LauncherOptions(config: [file.toFile().canonicalPath]) - def run = new RunImpl( Mock(RunImpl.Options) { withoutConda >> true } ) + def opt = new CliOptions.V1(config: [file.toFile().canonicalPath]) + def run = new CmdRun( Mock(CmdRun.Options) { withoutConda >> true } ) def config = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).build() then: !config.conda.enabled @@ -1236,14 +1236,14 @@ class ConfigBuilderTest extends Specification { when: def config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: !config.spack when: config = new ConfigObject() config.spack.createOptions = 'something' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: config.spack instanceof Map !config.spack.enabled @@ -1251,7 +1251,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withSpack >> 'my-recipe.yaml' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withSpack >> 'my-recipe.yaml' })) then: config.spack instanceof Map config.spack.enabled @@ -1260,7 +1260,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() config.spack.enabled = true - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withSpack >> 'my-recipe.yaml' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withSpack >> 'my-recipe.yaml' })) then: config.spack instanceof Map config.spack.enabled @@ -1269,7 +1269,7 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() config.process.spack = 'my-recipe.yaml' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { withSpack >> '-' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { withSpack >> '-' })) then: config.spack instanceof Map config.spack.enabled @@ -1288,8 +1288,8 @@ class ConfigBuilderTest extends Specification { ''' when: - def opt = new LauncherOptions(config: [file.toFile().canonicalPath]) - def run = new RunImpl( Mock(RunImpl.Options) { withoutSpack >> true }) + def opt = new CliOptions.V1(config: [file.toFile().canonicalPath]) + def run = new CmdRun( Mock(CmdRun.Options) { withoutSpack >> true }) def config = new ConfigBuilder().setLauncherOptions(opt).setRunOptions(run).build() then: !config.spack.enabled @@ -1304,28 +1304,28 @@ class ConfigBuilderTest extends Specification { when: def config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: !config.isSet('resume') when: config = new ConfigObject() config.resume ='alpha-beta-delta' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: config.resume == 'alpha-beta-delta' when: config = new ConfigObject() config.resume ='alpha-beta-delta' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { resume >> 'xxx-yyy' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { resume >> 'xxx-yyy' })) then: config.resume == 'xxx-yyy' when: config = new ConfigObject() config.resume ='this-that' - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { resume >> 'xxx-yyy' })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { resume >> 'xxx-yyy' })) then: config.resume == 'xxx-yyy' } @@ -1337,27 +1337,27 @@ class ConfigBuilderTest extends Specification { def builder = [:] as ConfigBuilder when: - builder.configRunOptions(config, [:], new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, [:], new CmdRun( Mock(CmdRun.Options) )) then: config.workDir == 'work' when: config = new ConfigObject() - builder.configRunOptions(config, [NXF_WORK: '/foo/bar'], new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, [NXF_WORK: '/foo/bar'], new CmdRun( Mock(CmdRun.Options) )) then: config.workDir == '/foo/bar' when: config = new ConfigObject() config.workDir = 'hello/there' - builder.configRunOptions(config, [:], new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, [:], new CmdRun( Mock(CmdRun.Options) )) then: config.workDir == 'hello/there' when: config = new ConfigObject() config.workDir = 'hello/there' - builder.configRunOptions(config, [:], new RunImpl( Mock(RunImpl.Options) { workDir >> 'my/work/dir' })) + builder.configRunOptions(config, [:], new CmdRun( Mock(CmdRun.Options) { workDir >> 'my/work/dir' })) then: config.workDir == 'my/work/dir' } @@ -1368,17 +1368,17 @@ class ConfigBuilderTest extends Specification { def builder = [:] as ConfigBuilder when: - builder.configRunOptions(config, [:], new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, [:], new CmdRun( Mock(CmdRun.Options) )) then: !config.isSet('libDir') when: - builder.configRunOptions(config, [NXF_LIB:'/foo/bar'], new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, [NXF_LIB:'/foo/bar'], new CmdRun( Mock(CmdRun.Options) )) then: config.libDir == '/foo/bar' when: - builder.configRunOptions(config, [:], new RunImpl( Mock(RunImpl.Options) { libPath >> 'my/lib/dir' })) + builder.configRunOptions(config, [:], new CmdRun( Mock(CmdRun.Options) { libPath >> 'my/lib/dir' })) then: config.libDir == 'my/lib/dir' } @@ -1391,19 +1391,19 @@ class ConfigBuilderTest extends Specification { when: config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) )) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) )) then: !config.isSet('cacheable') when: config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { cacheable >> false })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { cacheable >> false })) then: config.cacheable == false when: config = new ConfigObject() - builder.configRunOptions(config, env, new RunImpl( Mock(RunImpl.Options) { cacheable >> true })) + builder.configRunOptions(config, env, new CmdRun( Mock(CmdRun.Options) { cacheable >> true })) then: config.cacheable == true } @@ -1461,19 +1461,19 @@ class ConfigBuilderTest extends Specification { def builder when: - builder = new ConfigBuilder().setRunOptions(new RunImpl( Mock(RunImpl.Options) { profile >> 'foo' })) + builder = new ConfigBuilder().setRunOptions(new CmdRun( Mock(CmdRun.Options) { profile >> 'foo' })) then: builder.profile == 'foo' builder.validateProfile when: - builder = new ConfigBuilder().setRunOptions(new RunImpl( Mock(RunImpl.Options) )) + builder = new ConfigBuilder().setRunOptions(new CmdRun( Mock(CmdRun.Options) )) then: builder.profile == 'standard' !builder.validateProfile when: - builder = new ConfigBuilder().setRunOptions(new RunImpl( Mock(RunImpl.Options) { profile >> 'standard' })) + builder = new ConfigBuilder().setRunOptions(new CmdRun( Mock(CmdRun.Options) { profile >> 'standard' })) then: builder.profile == 'standard' builder.validateProfile @@ -1484,20 +1484,20 @@ class ConfigBuilderTest extends Specification { def builder when: - options = Mock(ConfigImpl.Options) - builder = new ConfigBuilder().setCmdConfig(new ConfigImpl(options)) + options = Mock(CmdConfig.Options) + builder = new ConfigBuilder().setCmdConfig(new CmdConfig(options)) then: !builder.showAllProfiles when: - options = Mock(ConfigImpl.Options) { showAllProfiles >> true } - builder = new ConfigBuilder().setCmdConfig(new ConfigImpl(options)) + options = Mock(CmdConfig.Options) { showAllProfiles >> true } + builder = new ConfigBuilder().setCmdConfig(new CmdConfig(options)) then: builder.showAllProfiles when: - options = Mock(ConfigImpl.Options) { profile >> 'foo' } - builder = new ConfigBuilder().setCmdConfig(new ConfigImpl(options)) + options = Mock(CmdConfig.Options) { profile >> 'foo' } + builder = new ConfigBuilder().setCmdConfig(new CmdConfig(options)) then: builder.profile == 'foo' builder.validateProfile @@ -1540,56 +1540,56 @@ class ConfigBuilderTest extends Specification { def config when: - config = new ConfigBuilder().setLauncherOptions(new LauncherOptions(config: EMPTY)).setRunOptions(new RunImpl( Mock(RunImpl.Options) )).build() + config = new ConfigBuilder().setLauncherOptions(new CliOptions.V1(config: EMPTY)).setRunOptions(new CmdRun( Mock(CmdRun.Options) )).build() then: config.params == [:] // get params for the CLI when: - config = new ConfigBuilder().setLauncherOptions(new LauncherOptions(config: EMPTY)).setRunOptions(new RunImpl( Mock(RunImpl.Options) { params >> [foo:'one', bar:'two'] })).build() + config = new ConfigBuilder().setLauncherOptions(new CliOptions.V1(config: EMPTY)).setRunOptions(new CmdRun( Mock(CmdRun.Options) { params >> [foo:'one', bar:'two'] })).build() then: config.params == [foo:'one', bar:'two'] // get params from config file when: - config = new ConfigBuilder().setLauncherOptions(new LauncherOptions(config: [configFile])).setRunOptions(new RunImpl( Mock(RunImpl.Options) )).build() + config = new ConfigBuilder().setLauncherOptions(new CliOptions.V1(config: [configFile])).setRunOptions(new CmdRun( Mock(CmdRun.Options) )).build() then: config.params == [foo:1, bar:2, data: '/some/path'] // get params form JSON file when: - config = new ConfigBuilder().setLauncherOptions(new LauncherOptions(config: EMPTY)).setRunOptions(new RunImpl( Mock(RunImpl.Options) { paramsFile >> jsonFile })).build() + config = new ConfigBuilder().setLauncherOptions(new CliOptions.V1(config: EMPTY)).setRunOptions(new CmdRun( Mock(CmdRun.Options) { paramsFile >> jsonFile })).build() then: config.params == [foo:10, bar:20] // get params from YAML file when: - config = new ConfigBuilder().setLauncherOptions(new LauncherOptions(config: EMPTY)).setRunOptions(new RunImpl( Mock(RunImpl.Options) { paramsFile >> yamlFile })).build() + config = new ConfigBuilder().setLauncherOptions(new CliOptions.V1(config: EMPTY)).setRunOptions(new CmdRun( Mock(CmdRun.Options) { paramsFile >> yamlFile })).build() then: config.params == [foo:100, bar:200] // cli override config when: - config = new ConfigBuilder().setLauncherOptions(new LauncherOptions(config: [configFile])).setRunOptions(new RunImpl( Mock(RunImpl.Options) { params >> [foo:'hello', baz:'world'] })).build() + config = new ConfigBuilder().setLauncherOptions(new CliOptions.V1(config: [configFile])).setRunOptions(new CmdRun( Mock(CmdRun.Options) { params >> [foo:'hello', baz:'world'] })).build() then: config.params == [foo:'hello', bar:2, baz: 'world', data: '/some/path'] // CLI override JSON when: - config = new ConfigBuilder().setLauncherOptions(new LauncherOptions(config: EMPTY)).setRunOptions(new RunImpl( Mock(RunImpl.Options) { params >> [foo:'hello', baz:'world'] ; paramsFile >> jsonFile })).build() + config = new ConfigBuilder().setLauncherOptions(new CliOptions.V1(config: EMPTY)).setRunOptions(new CmdRun( Mock(CmdRun.Options) { params >> [foo:'hello', baz:'world'] ; paramsFile >> jsonFile })).build() then: config.params == [foo:'hello', bar:20, baz: 'world'] // JSON override config when: - config = new ConfigBuilder().setLauncherOptions(new LauncherOptions(config: [configFile])).setRunOptions(new RunImpl( Mock(RunImpl.Options) { paramsFile >> jsonFile })).build() + config = new ConfigBuilder().setLauncherOptions(new CliOptions.V1(config: [configFile])).setRunOptions(new CmdRun( Mock(CmdRun.Options) { paramsFile >> jsonFile })).build() then: config.params == [foo:10, bar:20, data: '/some/path'] // CLI override JSON that override config when: - config = new ConfigBuilder().setLauncherOptions(new LauncherOptions(config: [configFile])).setRunOptions(new RunImpl( Mock(RunImpl.Options) { paramsFile >> jsonFile ; params >> [foo:'Ciao'] })).build() + config = new ConfigBuilder().setLauncherOptions(new CliOptions.V1(config: [configFile])).setRunOptions(new CmdRun( Mock(CmdRun.Options) { paramsFile >> jsonFile ; params >> [foo:'Ciao'] })).build() then: config.params == [foo:'Ciao', bar:20, data: '/some/path'] } @@ -1597,7 +1597,7 @@ class ConfigBuilderTest extends Specification { def 'should run with conda' () { when: - def config = new ConfigBuilder().setRunOptions(new RunImpl( Mock(RunImpl.Options) { withConda >> '/some/path/env.yml' })).build() + def config = new ConfigBuilder().setRunOptions(new CmdRun( Mock(CmdRun.Options) { withConda >> '/some/path/env.yml' })).build() then: config.process.conda == '/some/path/env.yml' @@ -1606,7 +1606,7 @@ class ConfigBuilderTest extends Specification { def 'should run with spack' () { when: - def config = new ConfigBuilder().setRunOptions(new RunImpl( Mock(RunImpl.Options) { withSpack >> '/some/path/env.yaml' })).build() + def config = new ConfigBuilder().setRunOptions(new CmdRun( Mock(CmdRun.Options) { withSpack >> '/some/path/env.yaml' })).build() then: config.process.spack == '/some/path/env.yaml' @@ -1624,7 +1624,7 @@ class ConfigBuilderTest extends Specification { when: - def opt = new LauncherOptions(config: [file.toFile().canonicalPath] ) + def opt = new CliOptions.V1(config: [file.toFile().canonicalPath] ) def cfg = new ConfigBuilder().setLauncherOptions(opt).build() then: cfg.params.foo == System.getenv('HOME') @@ -1634,7 +1634,7 @@ class ConfigBuilderTest extends Specification { ''' params.foo = bar ''' - opt = new LauncherOptions(config: [file.toFile().canonicalPath] ) + opt = new CliOptions.V1(config: [file.toFile().canonicalPath] ) new ConfigBuilder().setLauncherOptions(opt).build() then: def e = thrown(ConfigParseException) @@ -1653,7 +1653,7 @@ class ConfigBuilderTest extends Specification { ''' when: - def opt = new LauncherOptions(config: [file.toFile().canonicalPath] ) + def opt = new CliOptions.V1(config: [file.toFile().canonicalPath] ) def builder = new ConfigBuilder() .setLauncherOptions(opt) .showMissingVariables(true) @@ -1682,7 +1682,7 @@ class ConfigBuilderTest extends Specification { ''' params.x = foo.bar ''' - def opt = new LauncherOptions(config: [file.toFile().canonicalPath] ) + def opt = new CliOptions.V1(config: [file.toFile().canonicalPath] ) new ConfigBuilder().setLauncherOptions(opt).build() then: def e = thrown(ConfigParseException) @@ -1723,23 +1723,23 @@ class ConfigBuilderTest extends Specification { Map config when: - config = new ConfigBuilder().setRunOptions(new RunImpl( Mock(RunImpl.Options) )).build() + config = new ConfigBuilder().setRunOptions(new CmdRun( Mock(CmdRun.Options) )).build() then: !config.notification when: - config = new ConfigBuilder().setRunOptions(new RunImpl( Mock(RunImpl.Options) { withNotification >> true })).build() + config = new ConfigBuilder().setRunOptions(new CmdRun( Mock(CmdRun.Options) { withNotification >> true })).build() then: config.notification.enabled == true when: - config = new ConfigBuilder().setRunOptions(new RunImpl( Mock(RunImpl.Options) { withNotification >> false })).build() + config = new ConfigBuilder().setRunOptions(new CmdRun( Mock(CmdRun.Options) { withNotification >> false })).build() then: config.notification.enabled == false config.notification.to == null when: - config = new ConfigBuilder().setRunOptions(new RunImpl( Mock(RunImpl.Options) { withNotification >> 'yo@nextflow.com' })).build() + config = new ConfigBuilder().setRunOptions(new CmdRun( Mock(CmdRun.Options) { withNotification >> 'yo@nextflow.com' })).build() then: config.notification.enabled == true config.notification.to == 'yo@nextflow.com' @@ -1751,22 +1751,22 @@ class ConfigBuilderTest extends Specification { Map config when: - config = new ConfigBuilder().setRunOptions(new RunImpl( Mock(RunImpl.Options) )).build() + config = new ConfigBuilder().setRunOptions(new CmdRun( Mock(CmdRun.Options) )).build() then: !config.fusion when: - config = new ConfigBuilder().setRunOptions(new RunImpl( Mock(RunImpl.Options) { withFusion >> true })).build() + config = new ConfigBuilder().setRunOptions(new CmdRun( Mock(CmdRun.Options) { withFusion >> true })).build() then: config.fusion.enabled == true when: - config = new ConfigBuilder().setRunOptions(new RunImpl( Mock(RunImpl.Options) { withFusion >> false })).build() + config = new ConfigBuilder().setRunOptions(new CmdRun( Mock(CmdRun.Options) { withFusion >> false })).build() then: config.fusion == [enabled: false] when: - config = new ConfigBuilder().setRunOptions(new RunImpl( Mock(RunImpl.Options) { withFusion >> true })).build() + config = new ConfigBuilder().setRunOptions(new CmdRun( Mock(CmdRun.Options) { withFusion >> true })).build() then: config.fusion == [enabled: true] } @@ -1776,12 +1776,12 @@ class ConfigBuilderTest extends Specification { Map config when: - config = new ConfigBuilder().setRunOptions(new RunImpl( Mock(RunImpl.Options) )).build() + config = new ConfigBuilder().setRunOptions(new CmdRun( Mock(CmdRun.Options) )).build() then: !config.stubRun when: - config = new ConfigBuilder().setRunOptions(new RunImpl( Mock(RunImpl.Options) { stubRun >> true })).build() + config = new ConfigBuilder().setRunOptions(new CmdRun( Mock(CmdRun.Options) { stubRun >> true })).build() then: config.stubRun == true } @@ -2151,8 +2151,8 @@ class ConfigBuilderTest extends Specification { """ when: - def opt = new LauncherOptions() - def run = new RunImpl( Mock(RunImpl.Options) { params >> [bar: "world", 'baz.y': "mondo", 'baz.z.beta': "Welt"] }) + def opt = new CliOptions.V1() + def run = new CmdRun( Mock(CmdRun.Options) { params >> [bar: "world", 'baz.y': "mondo", 'baz.z.beta': "Welt"] }) def config = new ConfigBuilder(env: [NXF_CONFIG_FILE: configMain.toString()]).setLauncherOptions(opt).setRunOptions(run).build() then: @@ -2228,7 +2228,7 @@ class ConfigBuilderTest extends Specification { when: def cfg1 = new ConfigBuilder() - .setLauncherOptions( new LauncherOptions(userConfig: [config.toString()])) + .setLauncherOptions( new CliOptions.V1(userConfig: [config.toString()])) .build() then: cfg1.params.test.foo == "foo_def" @@ -2237,8 +2237,8 @@ class ConfigBuilderTest extends Specification { when: def cfg2 = new ConfigBuilder() - .setLauncherOptions( new LauncherOptions(userConfig: [config.toString()])) - .setRunOptions( new RunImpl( Mock(RunImpl.Options) { params >> ['test.foo': 'CLI_FOO'] })) + .setLauncherOptions( new CliOptions.V1(userConfig: [config.toString()])) + .setRunOptions( new CmdRun( Mock(CmdRun.Options) { params >> ['test.foo': 'CLI_FOO'] })) .build() then: cfg2.params.test.foo == "CLI_FOO" @@ -2269,7 +2269,7 @@ class ConfigBuilderTest extends Specification { '''.stripIndent() when: - def cfg1 = new ConfigBuilder().setRunOptions(new RunImpl( Mock(RunImpl.Options) { paramsFile >> config.toString() })).build() + def cfg1 = new ConfigBuilder().setRunOptions(new CmdRun( Mock(CmdRun.Options) { paramsFile >> config.toString() })).build() then: cfg1.params.title == "something" @@ -2297,7 +2297,7 @@ class ConfigBuilderTest extends Specification { '''.stripIndent() when: - def cfg1 = new ConfigBuilder().setRunOptions(new RunImpl( Mock(RunImpl.Options) { paramsFile >> config.toString() })).build() + def cfg1 = new ConfigBuilder().setRunOptions(new CmdRun( Mock(CmdRun.Options) { paramsFile >> config.toString() })).build() then: cfg1.params.title == "something" @@ -2312,7 +2312,7 @@ class ConfigBuilderTest extends Specification { def 'should return parsed config' () { given: - def cmd = new RunImpl( Mock(RunImpl.Options) { profile >> 'first' ; withTower >> 'http://foo.com' ; launcher: new Launcher() }) + def cmd = new CmdRun( Mock(CmdRun.Options) { profile >> 'first' ; withTower >> 'http://foo.com' ; launcher: new Launcher() }) def base = Files.createTempDirectory('test') base.resolve('nextflow.config').text = ''' profiles { diff --git a/modules/nextflow/src/test/groovy/nextflow/k8s/K8sDriverLauncherTest.groovy b/modules/nextflow/src/test/groovy/nextflow/k8s/K8sDriverLauncherTest.groovy index 785d8b9d4e..3132649dfe 100644 --- a/modules/nextflow/src/test/groovy/nextflow/k8s/K8sDriverLauncherTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/k8s/K8sDriverLauncherTest.groovy @@ -18,9 +18,9 @@ package nextflow.k8s import java.nio.file.Files -import nextflow.cli.v1.KubeRunCmd -import nextflow.cli.v1.Launcher -import nextflow.cli.v1.LauncherOptions +import nextflow.cli.CmdKubeRun +import nextflow.cli.Launcher +import nextflow.cli.CliOptions import nextflow.k8s.client.ClientConfig import nextflow.k8s.client.K8sClient import nextflow.k8s.model.PodMountConfig @@ -93,36 +93,36 @@ class K8sDriverLauncherTest extends Specification { def l = new K8sDriverLauncher(cmd: cmd, pipelineName: 'foo') when: - cmd.launcher = new Launcher(options: new LauncherOptions()) + cmd.launcher = new Launcher(options: new CliOptions.V1()) then: l.getLaunchCli() == expected where: cmd | expected - new KubeRunCmd() | 'nextflow run foo' - new KubeRunCmd(cacheable: false) | 'nextflow run foo -cache false' - new KubeRunCmd(resume: true) | 'nextflow run foo -resume true' - new KubeRunCmd(poolSize: 10) | 'nextflow run foo -ps 10' - new KubeRunCmd(pollInterval: 5) | 'nextflow run foo -pi 5' - new KubeRunCmd(queueSize: 9) | 'nextflow run foo -qs 9' - new KubeRunCmd(revision: 'xyz') | 'nextflow run foo -r xyz' - new KubeRunCmd(latest: true) | 'nextflow run foo -latest true' - new KubeRunCmd(withTrace: true) | 'nextflow run foo -with-trace true' - new KubeRunCmd(withTimeline: true) | 'nextflow run foo -with-timeline true' - new KubeRunCmd(withDag: true) | 'nextflow run foo -with-dag true' - new KubeRunCmd(dumpHashes: true) | 'nextflow run foo -dump-hashes true' - new KubeRunCmd(dumpChannels: 'lala') | 'nextflow run foo -dump-channels lala' - new KubeRunCmd(env: [XX:'hello', YY: 'world']) | 'nextflow run foo -e.XX hello -e.YY world' - new KubeRunCmd(processOptions: [mem: '100',cpus:'2']) | 'nextflow run foo -process.mem 100 -process.cpus 2' - new KubeRunCmd(params: [alpha:'x', beta:'y']) | 'nextflow run foo --alpha x --beta y' - new KubeRunCmd(params: [alpha: '/path/*.txt']) | 'nextflow run foo --alpha /path/\\*.txt' - new KubeRunCmd(entryName: 'lala') | 'nextflow run foo -entry lala' + new CmdKubeRun() | 'nextflow run foo' + new CmdKubeRun(cacheable: false) | 'nextflow run foo -cache false' + new CmdKubeRun(resume: true) | 'nextflow run foo -resume true' + new CmdKubeRun(poolSize: 10) | 'nextflow run foo -ps 10' + new CmdKubeRun(pollInterval: 5) | 'nextflow run foo -pi 5' + new CmdKubeRun(queueSize: 9) | 'nextflow run foo -qs 9' + new CmdKubeRun(revision: 'xyz') | 'nextflow run foo -r xyz' + new CmdKubeRun(latest: true) | 'nextflow run foo -latest true' + new CmdKubeRun(withTrace: true) | 'nextflow run foo -with-trace true' + new CmdKubeRun(withTimeline: true) | 'nextflow run foo -with-timeline true' + new CmdKubeRun(withDag: true) | 'nextflow run foo -with-dag true' + new CmdKubeRun(dumpHashes: true) | 'nextflow run foo -dump-hashes true' + new CmdKubeRun(dumpChannels: 'lala') | 'nextflow run foo -dump-channels lala' + new CmdKubeRun(env: [XX:'hello', YY: 'world']) | 'nextflow run foo -e.XX hello -e.YY world' + new CmdKubeRun(processOptions: [mem: '100',cpus:'2']) | 'nextflow run foo -process.mem 100 -process.cpus 2' + new CmdKubeRun(params: [alpha:'x', beta:'y']) | 'nextflow run foo --alpha x --beta y' + new CmdKubeRun(params: [alpha: '/path/*.txt']) | 'nextflow run foo --alpha /path/\\*.txt' + new CmdKubeRun(entryName: 'lala') | 'nextflow run foo -entry lala' } def 'should set the run name' () { given: - def cmd = new KubeRunCmd() - cmd.launcher = new Launcher(options: new LauncherOptions()) + def cmd = new CmdKubeRun() + cmd.launcher = new Launcher(options: new CliOptions.V1()) when: def l = new K8sDriverLauncher(cmd: cmd, pipelineName: 'foo', runName: 'bar') @@ -406,7 +406,7 @@ class K8sDriverLauncherTest extends Specification { when: driver.@config = NXF_CONFIG driver.@k8sConfig = K8S_CONFIG - driver.@cmd = new KubeRunCmd(paramsFile: params.toString()) + driver.@cmd = new CmdKubeRun(paramsFile: params.toString()) driver.createK8sConfigMap() then: @@ -453,7 +453,7 @@ class K8sDriverLauncherTest extends Specification { when: driver.@config = NXF_CONFIG driver.@k8sConfig = K8S_CONFIG - driver.@cmd = new KubeRunCmd(paramsFile: params.toString()) + driver.@cmd = new CmdKubeRun(paramsFile: params.toString()) driver.createK8sConfigMap() then: @@ -485,7 +485,7 @@ class K8sDriverLauncherTest extends Specification { CFG_WITH_MOUNTS.k8s.storageMountPath = '/foo' when: - driver.@cmd = new KubeRunCmd() + driver.@cmd = new CmdKubeRun() config = driver.makeConfig(NAME).toMap() then: 1 * driver.loadConfig(NAME) >> CFG_EMPTY @@ -495,7 +495,7 @@ class K8sDriverLauncherTest extends Specification { config.k8s.storageClaimName == null when: - driver.@cmd = new KubeRunCmd() + driver.@cmd = new CmdKubeRun() config = driver.makeConfig(NAME).toMap() then: 1 * driver.loadConfig(NAME) >> CFG_WITH_MOUNTS @@ -508,7 +508,7 @@ class K8sDriverLauncherTest extends Specification { new K8sConfig(config.k8s).getPodOptions() == new PodOptions([ [volumeClaim:'pvc', mountPath: '/foo'] ]) when: - driver.@cmd = new KubeRunCmd(volMounts: ['pvc-1:/this','pvc-2:/that'] ) + driver.@cmd = new CmdKubeRun(volMounts: ['pvc-1:/this','pvc-2:/that'] ) config = driver.makeConfig(NAME).toMap() then: 1 * driver.loadConfig(NAME) >> CFG_EMPTY @@ -526,7 +526,7 @@ class K8sDriverLauncherTest extends Specification { when: - driver.@cmd = new KubeRunCmd(volMounts: ['xyz:/this'] ) + driver.@cmd = new CmdKubeRun(volMounts: ['xyz:/this'] ) config = driver.makeConfig(NAME).toMap() then: 1 * driver.loadConfig(NAME) >> CFG_WITH_MOUNTS @@ -543,7 +543,7 @@ class K8sDriverLauncherTest extends Specification { when: - driver.@cmd = new KubeRunCmd(volMounts: ['xyz', 'bar:/mnt/bar'] ) + driver.@cmd = new CmdKubeRun(volMounts: ['xyz', 'bar:/mnt/bar'] ) config = driver.makeConfig(NAME).toMap() then: 1 * driver.loadConfig(NAME) >> CFG_WITH_MOUNTS @@ -563,8 +563,8 @@ class K8sDriverLauncherTest extends Specification { def 'should add the plugin into the config' () { given: - def cmd = new KubeRunCmd() - cmd.launcher = new Launcher(options: new LauncherOptions()) + def cmd = new CmdKubeRun() + cmd.launcher = new Launcher(options: new CliOptions.V1()) when: def l = new K8sDriverLauncher(cmd: cmd, plugins: 'nf-cws@1.0.0', runName: 'bar') @@ -583,14 +583,14 @@ class K8sDriverLauncherTest extends Specification { CFG_WITH_MOUNTS.k8s.volumeClaims = [ pvc: [mountPath:'/foo'] ] when: - driver.@cmd = new KubeRunCmd() + driver.@cmd = new CmdKubeRun() config = driver.makeConfig(NAME).toMap() then: 1 * driver.loadConfig(NAME) >> CFG_EMPTY config.process.executor == 'k8s' when: - driver.@cmd = new KubeRunCmd() + driver.@cmd = new CmdKubeRun() config = driver.makeConfig(NAME).toMap() then: 1 * driver.loadConfig(NAME) >> CFG_WITH_MOUNTS @@ -599,7 +599,7 @@ class K8sDriverLauncherTest extends Specification { config.k8s.storageMountPath == '/foo' when: - driver.@cmd = new KubeRunCmd(volMounts: ['pvc-1:/this','pvc-2:/that'] ) + driver.@cmd = new CmdKubeRun(volMounts: ['pvc-1:/this','pvc-2:/that'] ) config = driver.makeConfig(NAME).toMap() then: 1 * driver.loadConfig(NAME) >> CFG_EMPTY @@ -610,7 +610,7 @@ class K8sDriverLauncherTest extends Specification { when: - driver.@cmd = new KubeRunCmd(volMounts: ['xyz:/this'] ) + driver.@cmd = new CmdKubeRun(volMounts: ['xyz:/this'] ) config = driver.makeConfig(NAME).toMap() then: 1 * driver.loadConfig(NAME) >> CFG_WITH_MOUNTS diff --git a/modules/nextflow/src/test/groovy/nextflow/util/LoggerHelperTest.groovy b/modules/nextflow/src/test/groovy/nextflow/util/LoggerHelperTest.groovy index acb864c10f..79d438e6ff 100644 --- a/modules/nextflow/src/test/groovy/nextflow/util/LoggerHelperTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/util/LoggerHelperTest.groovy @@ -22,7 +22,7 @@ import java.nio.file.Paths import ch.qos.logback.classic.Level import groovyx.gpars.dataflow.DataflowQueue import groovyx.gpars.dataflow.DataflowVariable -import nextflow.cli.ILauncherOptions +import nextflow.cli.CliOptions import nextflow.extension.OpCall import nextflow.script.BaseScript import nextflow.script.ScriptBinding @@ -64,7 +64,7 @@ class LoggerHelperTest extends Specification { def 'should create LoggerHelper object' () { given: - def logger = new LoggerHelper(Mock(ILauncherOptions)) + def logger = new LoggerHelper(Mock(CliOptions)) when: logger.setDaemon(true) then: diff --git a/modules/nextflow/src/test/groovy/nextflow/util/ProxyHelperTest.groovy b/modules/nextflow/src/test/groovy/nextflow/util/ProxyHelperTest.groovy index 5094808e12..ff0d59bd9a 100644 --- a/modules/nextflow/src/test/groovy/nextflow/util/ProxyHelperTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/util/ProxyHelperTest.groovy @@ -1,6 +1,5 @@ /* * Copyright 2020-2022, Seqera Labs - * Copyright 2013-2019, Centre for Genomic Regulation (CRG) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/plugins/nf-console/src/main/nextflow/ui/console/ConsoleRunner.groovy b/plugins/nf-console/src/main/nextflow/ui/console/ConsoleRunner.groovy index c21eee8e3d..ab7d01620a 100644 --- a/plugins/nf-console/src/main/nextflow/ui/console/ConsoleRunner.groovy +++ b/plugins/nf-console/src/main/nextflow/ui/console/ConsoleRunner.groovy @@ -18,7 +18,7 @@ package nextflow.ui.console import javax.swing.UIManager import groovy.util.logging.Slf4j -import nextflow.cli.LauncherOptions +import nextflow.cli.CliOptions import nextflow.util.LoggerHelper import org.codehaus.groovy.runtime.StackTraceUtils @@ -39,7 +39,7 @@ class ConsoleRunner implements ConsoleExtension { */ @Override void run(String script) { - LauncherOptions opts = new LauncherOptions() + def opts = new CliOptions.V1() opts.logFile = '.nextflow-console.log' new LoggerHelper(opts).setup() diff --git a/plugins/nf-console/src/main/nextflow/ui/console/Nextflow.groovy b/plugins/nf-console/src/main/nextflow/ui/console/Nextflow.groovy index f53e7b01a2..b8500763bd 100644 --- a/plugins/nf-console/src/main/nextflow/ui/console/Nextflow.groovy +++ b/plugins/nf-console/src/main/nextflow/ui/console/Nextflow.groovy @@ -27,7 +27,7 @@ import groovy.console.ui.OutputTransforms import groovy.util.logging.Slf4j import nextflow.NextflowMeta import nextflow.Session -import nextflow.cli.LauncherOptions +import nextflow.cli.CliOptions import nextflow.cli.CmdInfo import nextflow.cli.CmdRun import nextflow.config.ConfigBuilder @@ -83,7 +83,7 @@ class Nextflow extends Console { // create the config object return new ConfigBuilder() - .setLauncherOptions( new LauncherOptions() ) + .setLauncherOptions( new CliOptions.V1() ) .setBaseDir(base) .setRunOptions( new CmdRun() ) .build()