-
Notifications
You must be signed in to change notification settings - Fork 784
nextflow plugins -help: show subcommands
#7197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ewels
wants to merge
3
commits into
master
Choose a base branch
from
subcommand-help
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+152
−3
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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<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 ) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
defaultbranch aborts on the<plugin-name>:<command>form, which is the third invocation advertised in the top-level help just above (and arguably the primary purpose ofnextflow plugin).For example
nextflow plugin nf-hello:greet -helpparsesargs = ['nf-hello:greet'],command.helpis set, soLauncher.checkForHelp()callsusage()→usage(args).args[0]is neitherinstallnorcreate, so thisdefaultthrowsUnknown plugin sub-command: nf-hello:greet— i.e. asking for help on a documented, valid invocation produces an error claiming it does not exist. (Execution inrun()is fine — it handles the:form viaargs[0].contains(CMD_SEP); only the usage path aborts.)Suggest falling back to general usage for the
:form rather than aborting:This keeps the genuine typo error (e.g.
nextflow plugin instal -help) while not blowing up on the legitimate plugin-command form. Worth a test pinning the behavior down.