Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Sherman <[email protected]>
  • Loading branch information
bentsherman committed Jul 22, 2023
1 parent 40d3010 commit 3eae972
Show file tree
Hide file tree
Showing 53 changed files with 804 additions and 762 deletions.
137 changes: 137 additions & 0 deletions modules/nextflow/src/main/groovy/nextflow/cli/CliOptions.groovy
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
*/
@Slf4j
trait CliOptions {

abstract Boolean getAnsiLogCli()

abstract boolean isBackground()

abstract List<String> getConfig()

abstract List<String> getDebug()

abstract boolean getIgnoreConfigIncludes()

abstract String getLogFile()

abstract boolean isQuiet()

abstract String getSyslog()

abstract List<String> getTrace()

abstract List<String> 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<String> config

@Parameter(names = ['-c','-config'], description = 'Add the specified file to configuration set')
List<String> userConfig

@Parameter(names = ['-config-ignore-includes'], description = 'Disable the parsing of config includes')
boolean ignoreConfigIncludes

@DynamicParameter(names = ['-D'], description = 'Set JVM properties' )
Map<String,String> jvmOpts = [:]

@Parameter(names = ['-debug'], hidden = true)
List<String> 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<String> 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'
}

}
8 changes: 5 additions & 3 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdClean.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -59,7 +61,7 @@ class CmdClean implements CacheBase {
boolean getQuiet()
List<String> getArgs()

ILauncherOptions getLauncherOptions()
CliOptions getLauncherOptions()
}

@Parameters(commandDescription = 'Clean up project cache and work directories')
Expand Down Expand Up @@ -90,12 +92,12 @@ class CmdClean implements CacheBase {
List<String> args

@Override
ILauncherOptions getLauncherOptions() {
CliOptions getLauncherOptions() {
launcher.options
}

@Override
String getName() { 'clean' }
String getName() { NAME }

@Override
void run() {
Expand Down
10 changes: 6 additions & 4 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdClone.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> args
Expand All @@ -59,7 +61,7 @@ class CmdClone {
}

@Override
String getName() { 'clone' }
final String getName() { NAME }

@Override
void run() {
Expand Down
10 changes: 6 additions & 4 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdConfig.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import nextflow.util.ConfigHelper
@CompileStatic
class CmdConfig {

static final public NAME = 'config'

interface Options {
String getPipeline()
boolean getShowAllProfiles()
Expand All @@ -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')
Expand All @@ -76,12 +78,12 @@ class CmdConfig {
}

@Override
ILauncherOptions getLauncherOptions() {
CliOptions getLauncherOptions() {
launcher.options
}

@Override
String getName() { 'config' }
String getName() { NAME }

@Override
void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 4 additions & 2 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdDrop.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -51,7 +53,7 @@ class CmdDrop {
String getPipeline() { args[0] }

@Override
String getName() { 'drop' }
final String getName() { NAME }

@Override
void run() {
Expand Down
Loading

0 comments on commit 3eae972

Please sign in to comment.