Skip to content

Commit

Permalink
Put CLI v1 code back into original command classes
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Sherman <[email protected]>
  • Loading branch information
bentsherman committed Jul 21, 2023
1 parent fcbddf5 commit fc54c4e
Show file tree
Hide file tree
Showing 71 changed files with 1,360 additions and 1,777 deletions.
2 changes: 1 addition & 1 deletion launch-v1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

MAIN_CLASS="nextflow.cli.v1.Launcher" ./launch.sh "$@"
MAIN_CLASS="nextflow.cli.Launcher" ./launch.sh "$@"
2 changes: 1 addition & 1 deletion launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fi
declare -a args=()
DEBUG=''
COLUMNS=${COLUMNS:-`tput cols 2> /dev/tty`}
MAIN_CLASS=${MAIN_CLASS:-'nextflow.cli.v1.Launcher'}
MAIN_CLASS=${MAIN_CLASS:-'nextflow.cli.Launcher'}
JAVA_VER="$($JAVA_BIN -version 2>&1)"
if [ $? -ne 0 ]; then
echo "${JAVA_VER:-Failed to launch the Java virtual machine}"
Expand Down
2 changes: 1 addition & 1 deletion modules/nextflow/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ test {
}

application {
mainClass = 'nextflow.cli.v1.Launcher'
mainClass = 'nextflow.cli.Launcher'
}

run{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import nextflow.util.HistoryFile
import static nextflow.util.HistoryFile.Record

/**
* Common cache operations shared by {@link LogImpl} and {@link CleanImpl}
* Common cache operations shared by {@link CmdLog} and {@link CmdClean}
*
* @author Paolo Di Tommaso <[email protected]>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package nextflow.cli.v1
package nextflow.cli

import com.beust.jcommander.Parameter
import groovy.transform.CompileStatic
Expand All @@ -25,7 +25,7 @@ import groovy.transform.CompileStatic
* @author Paolo Di Tommaso <[email protected]>
*/
@CompileStatic
abstract class AbstractCmd implements Runnable {
abstract class CmdBase implements Runnable {

private Launcher launcher

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

package nextflow.cli

import java.nio.file.FileVisitResult
import java.nio.file.FileVisitor
import java.nio.file.Files
Expand All @@ -24,6 +23,8 @@ import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.attribute.BasicFileAttributes

import com.beust.jcommander.Parameter
import com.beust.jcommander.Parameters
import com.google.common.hash.HashCode
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
Expand All @@ -39,14 +40,14 @@ import nextflow.trace.TraceRecord
import nextflow.util.HistoryFile.Record

/**
* CLI `clean` sub-command
* Implements cache clean up command
*
* @author Paolo Di Tommaso <[email protected]>
* @author Lorenz Gerber <[email protected]>
*/
@Slf4j
@CompileStatic
class CleanImpl implements CacheBase {
class CmdClean implements CacheBase {

interface Options {
String getAfter()
Expand All @@ -61,14 +62,56 @@ class CleanImpl implements CacheBase {
ILauncherOptions getLauncherOptions()
}

@Parameters(commandDescription = 'Clean up project cache and work directories')
static class V1 extends CmdBase implements Options {

@Parameter(names=['-q', '-quiet'], description = 'Do not print names of files removed', arity = 0)
boolean quiet

@Parameter(names=['-f', '-force'], description = 'Force clean command', arity = 0)
boolean force

@Parameter(names=['-n', '-dry-run'], description = 'Print names of file to be removed without deleting them' , arity = 0)
boolean dryRun

@Parameter(names='-after', description = 'Clean up runs executed after the specified one')
String after

@Parameter(names='-before', description = 'Clean up runs executed before the specified one')
String before

@Parameter(names='-but', description = 'Clean up all runs except the specified one')
String but

@Parameter(names=['-k', '-keep-logs'], description = 'Removes only temporary files but retains execution log entries and metadata')
boolean keepLogs

@Parameter
List<String> args

@Override
ILauncherOptions getLauncherOptions() {
launcher.options
}

@Override
String getName() { 'clean' }

@Override
void run() {
new CmdClean(this).run()
}

}

@Delegate
private Options options

private CacheDB currentCacheDb

private Map<HashCode, Short> dryHash = new HashMap<>()

CleanImpl(Options options) {
CmdClean(Options options) {
this.options = options
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
*/

package nextflow.cli

import com.beust.jcommander.Parameter
import com.beust.jcommander.Parameters
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import nextflow.exception.AbortOperationException
import nextflow.plugin.Plugins
import nextflow.scm.AssetManager

/**
* CLI `clone` sub-command
* CLI sub-command clone
*
* @author Paolo Di Tommaso <[email protected]>
*/
@Slf4j
@CompileStatic
class CloneImpl {
class CmdClone {

interface Options extends IHubOptions {
String getPipeline()
Expand All @@ -38,10 +38,39 @@ class CloneImpl {
String getRevision()
}

@Parameters(commandDescription = 'Clone a project into a folder')
static class V1 extends CmdBase implements Options, HubOptions {

@Parameter(required=true, description = 'name of the project to clone')
List<String> args

@Parameter(names='-r', description = 'Revision to clone - It can be a git branch, tag or revision number')
String revision

@Parameter(names=['-d','-deep'], description = 'Create a shallow clone of the specified depth')
Integer deep

@Override
String getPipeline() { args[0] }

@Override
String getTargetName() {
args.size() > 1 ? args[1] : null
}

@Override
String getName() { 'clone' }

@Override
void run() {
new CmdClone(this).run()
}
}

@Delegate
private Options options

CloneImpl(Options options) {
CmdClone(Options options) {
this.options = options
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package nextflow.cli
import java.nio.file.Path
import java.nio.file.Paths

import com.beust.jcommander.Parameter
import com.beust.jcommander.Parameters
import groovy.transform.CompileStatic
import groovy.transform.PackageScope
import groovy.util.logging.Slf4j
Expand All @@ -27,15 +29,14 @@ import nextflow.exception.AbortOperationException
import nextflow.plugin.Plugins
import nextflow.scm.AssetManager
import nextflow.util.ConfigHelper

/**
* CLI `config` sub-command
* Prints the pipeline configuration
*
* @author Paolo Di Tommaso <[email protected]>
*/
@Slf4j
@CompileStatic
class ConfigImpl {
class CmdConfig {

interface Options {
String getPipeline()
Expand All @@ -48,17 +49,58 @@ class ConfigImpl {
ILauncherOptions getLauncherOptions()
}

@Parameters(commandDescription = 'Print a project configuration')
static class V1 extends CmdBase implements Options {

@Parameter(description = 'project name')
List<String> args = []

@Parameter(names=['-a','-show-profiles'], description = 'Show all configuration profiles')
boolean showAllProfiles

@Parameter(names=['-profile'], description = 'Choose a configuration profile')
String profile

@Parameter(names = '-properties', description = 'Prints config using Java properties notation')
boolean printProperties

@Parameter(names = '-flat', description = 'Print config using flat notation')
boolean printFlatten

@Parameter(names = '-sort', description = 'Sort config attributes')
boolean sort

@Override
String getPipeline() {
args.size() > 0 ? args[0] : null
}

@Override
ILauncherOptions getLauncherOptions() {
launcher.options
}

@Override
String getName() { 'config' }

@Override
void run() {
new CmdConfig(this).run()
}

}

private OutputStream stdout = System.out

@Delegate
private Options options

ConfigImpl(Options options) {
CmdConfig(Options options) {
this.options = options
}

/* For testing purposes only */
ConfigImpl() {}
CmdConfig() {}

void run() {
Plugins.init()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,48 @@

package nextflow.cli

import com.beust.jcommander.Parameter
import com.beust.jcommander.Parameters
import groovy.transform.CompileStatic
import nextflow.plugin.Plugins
import nextflow.ui.console.ConsoleExtension

/**
* CLI `console` sub-command
* Launch the Nextflow Console plugin
*
* @author Paolo Di Tommaso <[email protected]>
*/
@CompileStatic
class ConsoleImpl {
class CmdConsole {

interface Options {
String getScript()
}

@Parameters(commandDescription = 'Launch Nextflow interactive console')
static class V1 extends CmdBase implements Options {

@Parameter(description = 'Nextflow console arguments')
List<String> args

@Override
String getScript() {
args.size() > 0 ? args[0] : null
}

@Override
String getName() { 'console' }

@Override
void run() {
new CmdConsole(this).run()
}
}

@Delegate
private Options options

ConsoleImpl(Options options) {
CmdConsole(Options options) {
this.options = options
}

Expand Down
Loading

0 comments on commit fc54c4e

Please sign in to comment.