Skip to content

Commit

Permalink
Merge pull request #2869 from pmoris/case
Browse files Browse the repository at this point in the history
Make module/subworkflow names case insensitive
  • Loading branch information
pmoris authored Mar 21, 2024
2 parents 70def9a + 2cdb907 commit 1148c4e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
- Fix issue with config resolution that was causing nested configs to behave unexpectedly ([#2862](https://github.com/nf-core/tools/pull/2862))
- Fix schema docs console output truncating ([#2880](https://github.com/nf-core/tools/pull/2880))
- fix: ensure path object converted to string before stripping quotes ([#2878](https://github.com/nf-core/tools/pull/2878))
- Make cli-provided module/subworkflow names case insensitive ([#2869](https://github.com/nf-core/tools/pull/2869))

## [v2.13.1 - Tin Puppy Patch](https://github.com/nf-core/tools/releases/tag/2.13) - [2024-02-29]

Expand Down
40 changes: 24 additions & 16 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ def selective_traceback_hook(exctype, value, traceback):
sys.excepthook = selective_traceback_hook


# Define callback function to normalize the case of click arguments,
# which is used to make the module/subworkflow names, provided by the
# user on the cli, case insensitive.
def normalize_case(ctx, param, component_name):
if component_name is not None:
return component_name.casefold()


def run_nf_core():
# print nf-core header if environment variable is not set
if os.environ.get("_NF_CORE_COMPLETE") is None:
Expand Down Expand Up @@ -786,7 +794,7 @@ def modules_list_local(ctx, keywords, json, dir): # pylint: disable=redefined-b
# nf-core modules install
@modules.command("install")
@click.pass_context
@click.argument("tool", type=str, required=False, metavar="<tool> or <tool/subtool>")
@click.argument("tool", type=str, callback=normalize_case, required=False, metavar="<tool> or <tool/subtool>")
@click.option(
"-d",
"--dir",
Expand Down Expand Up @@ -838,7 +846,7 @@ def modules_install(ctx, tool, dir, prompt, force, sha):
# nf-core modules update
@modules.command("update")
@click.pass_context
@click.argument("tool", type=str, required=False, metavar="<tool> or <tool/subtool>")
@click.argument("tool", type=str, callback=normalize_case, required=False, metavar="<tool> or <tool/subtool>")
@click.option(
"-d",
"--dir",
Expand Down Expand Up @@ -930,7 +938,7 @@ def modules_update(
# nf-core modules patch
@modules.command()
@click.pass_context
@click.argument("tool", type=str, required=False, metavar="<tool> or <tool/subtool>")
@click.argument("tool", type=str, callback=normalize_case, required=False, metavar="<tool> or <tool/subtool>")
@click.option(
"-d",
"--dir",
Expand Down Expand Up @@ -967,7 +975,7 @@ def patch(ctx, tool, dir, remove):
# nf-core modules remove
@modules.command("remove")
@click.pass_context
@click.argument("tool", type=str, required=False, metavar="<tool> or <tool/subtool>")
@click.argument("tool", type=str, callback=normalize_case, required=False, metavar="<tool> or <tool/subtool>")
@click.option(
"-d",
"--dir",
Expand Down Expand Up @@ -1121,7 +1129,7 @@ def create_module(
# nf-core modules test
@modules.command("test")
@click.pass_context
@click.argument("tool", type=str, required=False, metavar="<tool> or <tool/subtool>")
@click.argument("tool", type=str, callback=normalize_case, required=False, metavar="<tool> or <tool/subtool>")
@click.option(
"-d",
"--dir",
Expand Down Expand Up @@ -1180,7 +1188,7 @@ def test_module(ctx, tool, dir, no_prompts, update, once, profile):
# nf-core modules lint
@modules.command("lint")
@click.pass_context
@click.argument("tool", type=str, required=False, metavar="<tool> or <tool/subtool>")
@click.argument("tool", type=str, callback=normalize_case, required=False, metavar="<tool> or <tool/subtool>")
@click.option(
"-d",
"--dir",
Expand Down Expand Up @@ -1267,7 +1275,7 @@ def modules_lint(ctx, tool, dir, registry, key, all, fail_warned, local, passed,
# nf-core modules info
@modules.command("info")
@click.pass_context
@click.argument("tool", type=str, required=False, metavar="<tool> or <tool/subtool>")
@click.argument("tool", type=str, callback=normalize_case, required=False, metavar="<tool> or <tool/subtool>")
@click.option(
"-d",
"--dir",
Expand Down Expand Up @@ -1306,7 +1314,7 @@ def modules_info(ctx, tool, dir):
# nf-core modules bump-versions
@modules.command()
@click.pass_context
@click.argument("tool", type=str, required=False, metavar="<tool> or <tool/subtool>")
@click.argument("tool", type=str, callback=normalize_case, required=False, metavar="<tool> or <tool/subtool>")
@click.option(
"-d",
"--dir",
Expand Down Expand Up @@ -1392,7 +1400,7 @@ def create_subworkflow(ctx, subworkflow, dir, author, force, migrate_pytest):
# nf-core subworkflows test
@subworkflows.command("test")
@click.pass_context
@click.argument("subworkflow", type=str, required=False, metavar="subworkflow name")
@click.argument("subworkflow", type=str, callback=normalize_case, required=False, metavar="subworkflow name")
@click.option(
"-d",
"--dir",
Expand Down Expand Up @@ -1519,7 +1527,7 @@ def subworkflows_list_local(ctx, keywords, json, dir): # pylint: disable=redefi
# nf-core subworkflows lint
@subworkflows.command("lint")
@click.pass_context
@click.argument("subworkflow", type=str, required=False, metavar="subworkflow name")
@click.argument("subworkflow", type=str, callback=normalize_case, required=False, metavar="subworkflow name")
@click.option(
"-d",
"--dir",
Expand Down Expand Up @@ -1600,15 +1608,15 @@ def subworkflows_lint(ctx, subworkflow, dir, registry, key, all, fail_warned, lo
# nf-core subworkflows info
@subworkflows.command("info")
@click.pass_context
@click.argument("tool", type=str, required=False, metavar="subworkflow name")
@click.argument("subworkflow", type=str, callback=normalize_case, required=False, metavar="subworkflow name")
@click.option(
"-d",
"--dir",
type=click.Path(exists=True),
default=".",
help=r"Pipeline directory. [dim]\[default: Current working directory][/]",
)
def subworkflows_info(ctx, tool, dir):
def subworkflows_info(ctx, subworkflow, dir):
"""
Show developer usage information about a given subworkflow.
Expand All @@ -1625,7 +1633,7 @@ def subworkflows_info(ctx, tool, dir):
try:
subworkflow_info = SubworkflowInfo(
dir,
tool,
subworkflow,
ctx.obj["modules_repo_url"],
ctx.obj["modules_repo_branch"],
ctx.obj["modules_repo_no_pull"],
Expand All @@ -1639,7 +1647,7 @@ def subworkflows_info(ctx, tool, dir):
# nf-core subworkflows install
@subworkflows.command("install")
@click.pass_context
@click.argument("subworkflow", type=str, required=False, metavar="subworkflow name")
@click.argument("subworkflow", type=str, callback=normalize_case, required=False, metavar="subworkflow name")
@click.option(
"-d",
"--dir",
Expand Down Expand Up @@ -1697,7 +1705,7 @@ def subworkflows_install(ctx, subworkflow, dir, prompt, force, sha):
# nf-core subworkflows remove
@subworkflows.command("remove")
@click.pass_context
@click.argument("subworkflow", type=str, required=False, metavar="subworkflow name")
@click.argument("subworkflow", type=str, callback=normalize_case, required=False, metavar="subworkflow name")
@click.option(
"-d",
"--dir",
Expand Down Expand Up @@ -1727,7 +1735,7 @@ def subworkflows_remove(ctx, dir, subworkflow):
# nf-core subworkflows update
@subworkflows.command("update")
@click.pass_context
@click.argument("subworkflow", type=str, required=False, metavar="subworkflow name")
@click.argument("subworkflow", type=str, callback=normalize_case, required=False, metavar="subworkflow name")
@click.option(
"-d",
"--dir",
Expand Down

0 comments on commit 1148c4e

Please sign in to comment.