Skip to content

Commit fa17a9e

Browse files
authored
Merge pull request #882 from ewels/modules-fuzzy-finders
Make all modules commands use --tool and fuzzy module name input
2 parents bb663b1 + 122fcaa commit fa17a9e

File tree

6 files changed

+180
-148
lines changed

6 files changed

+180
-148
lines changed

.github/workflows/create-lint-wf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
nf-core --log-file log.txt sync nf-core-testpipeline/
3737
nf-core --log-file log.txt schema build nf-core-testpipeline/ --no-prompts
3838
nf-core --log-file log.txt bump-version nf-core-testpipeline/ 1.1
39-
nf-core --log-file log.txt modules install nf-core-testpipeline/ fastqc
39+
nf-core --log-file log.txt modules install nf-core-testpipeline/ --tool fastqc
4040
4141
- name: Upload log file artifact
4242
uses: actions/upload-artifact@v2

nf_core/__main__.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -367,22 +367,20 @@ def list(ctx, pipeline_dir, json):
367367
"""
368368
mods = nf_core.modules.PipelineModules()
369369
mods.modules_repo = ctx.obj["modules_repo_obj"]
370-
print(mods.list_modules(pipeline_dir, json))
370+
mods.pipeline_dir = pipeline_dir
371+
print(mods.list_modules(json))
371372

372373

373374
@modules.command(help_priority=2)
374375
@click.pass_context
375376
@click.argument("pipeline_dir", type=click.Path(exists=True), required=True, metavar="<pipeline directory>")
376-
@click.argument("tool", type=str, required=False, metavar="(<tool name>)")
377+
@click.option("-t", "--tool", type=str, metavar="<tool> or <tool/subtool>")
377378
def install(ctx, pipeline_dir, tool):
378379
"""
379380
Add a DSL2 software wrapper module to a pipeline.
380381
381-
Given a software name, finds the relevant files in nf-core/modules
382-
and copies to the pipeline along with associated metadata.
383-
384-
If <tool name> is not supplied on the command line, an interactive fuzzy-finder
385-
tool is given with available nf-core module names.
382+
Finds the relevant files in nf-core/modules and copies to the pipeline,
383+
along with associated metadata.
386384
"""
387385
try:
388386
mods = nf_core.modules.PipelineModules()
@@ -418,7 +416,7 @@ def install(ctx, pipeline_dir, tool):
418416
@modules.command(help_priority=4)
419417
@click.pass_context
420418
@click.argument("pipeline_dir", type=click.Path(exists=True), required=True, metavar="<pipeline directory>")
421-
@click.argument("tool", type=str, required=True, metavar="<tool name>")
419+
@click.option("-t", "--tool", type=str, metavar="<tool> or <tool/subtool>")
422420
def remove(ctx, pipeline_dir, tool):
423421
"""
424422
Remove a software wrapper from a pipeline.
@@ -436,7 +434,7 @@ def remove(ctx, pipeline_dir, tool):
436434
@modules.command("create", help_priority=5)
437435
@click.pass_context
438436
@click.argument("directory", type=click.Path(exists=True), required=True, metavar="<directory>")
439-
@click.argument("tool", type=str, required=True, metavar="<tool/subtool>")
437+
@click.option("-t", "--tool", type=str, metavar="<tool> or <tool/subtool>")
440438
@click.option("-a", "--author", type=str, metavar="<author>", help="Module author's GitHub username")
441439
@click.option("-l", "--label", type=str, metavar="<process label>", help="Standard resource label for process")
442440
@click.option("-m", "--meta", is_flag=True, default=False, help="Use Groovy meta map for sample information")
@@ -446,10 +444,6 @@ def create_module(ctx, directory, tool, author, label, meta, no_meta, force):
446444
"""
447445
Create a new DSL2 module from the nf-core template.
448446
449-
\b
450-
Tool should be named just <tool> or <tool/subtool>
451-
e.g fastqc or samtools/sort, respectively.
452-
453447
If <directory> is a pipeline, this function creates a file called
454448
'modules/local/tool_subtool.nf'
455449
@@ -476,23 +470,20 @@ def create_module(ctx, directory, tool, author, label, meta, no_meta, force):
476470

477471
@modules.command("create-test-yml", help_priority=6)
478472
@click.pass_context
479-
@click.argument("module", type=str, required=True, metavar="<module name>")
473+
@click.option("-t", "--tool", type=str, metavar="<tool> or <tool/subtool>")
480474
@click.option("-r", "--run-tests", is_flag=True, default=False, help="Run the test workflows")
481475
@click.option("-o", "--output", type=str, help="Path for output YAML file")
482476
@click.option("-f", "--force", is_flag=True, default=False, help="Overwrite output YAML file if it already exists")
483477
@click.option("-p", "--no-prompts", is_flag=True, default=False, help="Use defaults without prompting")
484-
def create_test_yml(ctx, module, run_tests, output, force, no_prompts):
478+
def create_test_yml(ctx, tool, run_tests, output, force, no_prompts):
485479
"""
486480
Auto-generate a test.yml file for a new module.
487481
488-
Given the name of a new module, run the Nextflow test command and automatically generate
482+
Given the name of a module, runs the Nextflow test command and automatically generate
489483
the required `test.yml` file based on the output files.
490-
491-
If not supplied on the command line, tool will prompt for name, command, tags etc with
492-
sensible defaults.
493484
"""
494485
try:
495-
meta_builder = nf_core.modules.ModulesTestYmlBuilder(module, run_tests, output, force, no_prompts)
486+
meta_builder = nf_core.modules.ModulesTestYmlBuilder(tool, run_tests, output, force, no_prompts)
496487
meta_builder.run()
497488
except UserWarning as e:
498489
log.critical(e)

nf_core/modules/create.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ def create(self):
7878
)
7979

8080
# Collect module info via prompt if empty or invalid
81+
if self.tool is None:
82+
self.tool = ""
8183
while self.tool == "" or re.search(r"[^a-z\d/]", self.tool) or self.tool.count("/") > 0:
8284

8385
# Check + auto-fix for invalid chacters

0 commit comments

Comments
 (0)