Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 54 additions & 3 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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<String> args) {
List<String> result = []
if( !args ) {
result << this.getClass().getAnnotation(Parameters).commandDescription()
result << 'Usage: nextflow plugin <sub-command> [options]'
result << ''
result << 'Commands:'
result << ' install <pluginId,...> Install a plugin'
result << ' create [<name> <provider> [dir]] Create a new plugin project from the template'
result << ' <plugin-name>:<command> [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 <pluginId,...>'
result << ''
break
case 'create':
result << 'Create a new plugin project from the official template'
result << 'Usage: nextflow plugin create [<plugin name> <provider name> [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 <pluginId,..>")
if( !args ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should print the reason of the failure before printing the usage

usage()
return
}
// setup plugins system
Plugins.init()
Runtime.addShutdownHook((it)-> Plugins.stop())
Expand Down
Loading