|
4 | 4 | import logging |
5 | 5 | import os |
6 | 6 | import sys |
| 7 | +from pathlib import Path |
7 | 8 |
|
8 | 9 | import rich |
9 | 10 | import rich.console |
@@ -696,12 +697,24 @@ def pipeline_schema(): |
696 | 697 |
|
697 | 698 | # nf-core pipelines schema validate |
698 | 699 | @pipeline_schema.command("validate") |
| 700 | +@click.option( |
| 701 | + "-d", |
| 702 | + "--dir", |
| 703 | + "directory", |
| 704 | + type=click.Path(exists=True), |
| 705 | + default=".", |
| 706 | + help=r"Pipeline directory. [dim]\[default: current working directory][/]", |
| 707 | +) |
699 | 708 | @click.argument("pipeline", required=True, metavar="<pipeline name>") |
700 | 709 | @click.argument("params", type=click.Path(exists=True), required=True, metavar="<JSON params file>") |
701 | | -def command_pipelines_schema_validate(pipeline, params): |
| 710 | +def command_pipelines_schema_validate(directory, pipeline, params): |
702 | 711 | """ |
703 | 712 | Validate a set of parameters against a pipeline schema. |
704 | 713 | """ |
| 714 | + if Path(directory, pipeline).exists(): |
| 715 | + # this is a local pipeline |
| 716 | + pipeline = Path(directory, pipeline) |
| 717 | + |
705 | 718 | pipelines_schema_validate(pipeline, params) |
706 | 719 |
|
707 | 720 |
|
@@ -740,23 +753,39 @@ def command_pipelines_schema_build(directory, no_prompts, web_only, url): |
740 | 753 |
|
741 | 754 | # nf-core pipelines schema lint |
742 | 755 | @pipeline_schema.command("lint") |
| 756 | +@click.option( |
| 757 | + "-d", |
| 758 | + "--dir", |
| 759 | + "directory", |
| 760 | + type=click.Path(exists=True), |
| 761 | + default=".", |
| 762 | + help=r"Pipeline directory. [dim]\[default: current working directory][/]", |
| 763 | +) |
743 | 764 | @click.argument( |
744 | | - "schema_path", |
| 765 | + "schema_file", |
745 | 766 | type=click.Path(exists=True), |
746 | 767 | default="nextflow_schema.json", |
747 | 768 | metavar="<pipeline schema>", |
748 | 769 | ) |
749 | | -def command_pipelines_schema_lint(schema_path): |
| 770 | +def command_pipelines_schema_lint(directory, schema_file): |
750 | 771 | """ |
751 | 772 | Check that a given pipeline schema is valid. |
752 | 773 | """ |
753 | | - pipelines_schema_lint(schema_path) |
| 774 | + pipelines_schema_lint(Path(directory, schema_file)) |
754 | 775 |
|
755 | 776 |
|
756 | 777 | # nf-core pipelines schema docs |
757 | 778 | @pipeline_schema.command("docs") |
| 779 | +@click.option( |
| 780 | + "-d", |
| 781 | + "--dir", |
| 782 | + "directory", |
| 783 | + type=click.Path(exists=True), |
| 784 | + default=".", |
| 785 | + help=r"Pipeline directory. [dim]\[default: current working directory][/]", |
| 786 | +) |
758 | 787 | @click.argument( |
759 | | - "schema_path", |
| 788 | + "schema_file", |
760 | 789 | type=click.Path(exists=True), |
761 | 790 | default="nextflow_schema.json", |
762 | 791 | required=False, |
@@ -785,11 +814,11 @@ def command_pipelines_schema_lint(schema_path): |
785 | 814 | help="CSV list of columns to include in the parameter tables (parameter,description,type,default,required,hidden)", |
786 | 815 | default="parameter,description,type,default,required,hidden", |
787 | 816 | ) |
788 | | -def command_pipelines_schema_docs(schema_path, output, format, force, columns): |
| 817 | +def command_pipelines_schema_docs(directory, schema_file, output, format, force, columns): |
789 | 818 | """ |
790 | 819 | Outputs parameter documentation for a pipeline schema. |
791 | 820 | """ |
792 | | - pipelines_schema_docs(schema_path, output, format, force, columns) |
| 821 | + pipelines_schema_docs(Path(directory, schema_file), output, format, force, columns) |
793 | 822 |
|
794 | 823 |
|
795 | 824 | # nf-core modules subcommands |
|
0 commit comments