diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdPlugin.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdPlugin.groovy index 231166bf34..d82f49a3ef 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdPlugin.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdPlugin.groovy @@ -35,7 +35,7 @@ import org.eclipse.jgit.api.Git */ @CompileStatic @Parameters(commandDescription = "Execute plugin-specific commands") -class CmdPlugin extends CmdBase { +class CmdPlugin extends CmdBase implements UsageAware { @Override String getName() { @@ -51,10 +51,61 @@ class CmdPlugin extends CmdBase { @Parameter(names = ['-template'], description = 'Plugin template version to use', hidden = true) String templateVersion = 'v0.3.0' + /** + * Print the command usage help + */ + @Override + void usage() { + usage(args) + } + + /** + * Print the command usage help + * + * @param args The arguments as entered by the user + */ + @Override + void usage(List args) { + List result = [] + if( !args ) { + result << this.getClass().getAnnotation(Parameters).commandDescription() + result << 'Usage: nextflow plugin [options]' + result << '' + result << 'Commands:' + result << ' install Install a plugin' + result << ' create [ [dir]] Create a new plugin project from the template' + result << ' : [args] Execute a plugin-specific command' + result << '' + result << 'See the documentation of an individual plugin for its plugin-specific commands.' + result << '' + } + else { + switch( args[0] ) { + case 'install': + result << 'Install a plugin' + result << 'Usage: nextflow plugin install ' + result << '' + break + case 'create': + result << 'Create a new plugin project from the official template' + result << 'Usage: nextflow plugin create [ [project path]]' + result << '' + result << 'When no arguments are provided, the command prompts interactively for the required values.' + result << '' + break + default: + throw new AbortOperationException("Unknown plugin sub-command: ${args[0]}") + } + } + println result.join('\n').toString() + } + @Override void run() { - if( !args ) - throw new AbortOperationException("Missing plugin command - usage: nextflow plugin install ") + if( !args ) { + usage() + return + } // setup plugins system Plugins.init() Runtime.addShutdownHook((it)-> Plugins.stop())