diff --git a/planemo/ci.py b/planemo/ci.py index 4de2c2061..d323138b7 100644 --- a/planemo/ci.py +++ b/planemo/ci.py @@ -61,6 +61,16 @@ def filter_paths(ctx, raw_paths, path_type="repo", **kwds): return chunked_paths +def group_paths(paths): + repos = {} + for path in paths: + repo = os.path.split(path)[0] + if repo not in repos: + repos[repo] = [] + repos[repo].append(path) + return [" ".join(repos[_]) for _ in repos] + + def print_path_list(paths, **kwds): with io.open_file_or_standard_output(kwds["output"], "w") as f: for path in paths: diff --git a/planemo/commands/cmd_ci_find_tools.py b/planemo/commands/cmd_ci_find_tools.py index e99b5f439..123823fd1 100644 --- a/planemo/commands/cmd_ci_find_tools.py +++ b/planemo/commands/cmd_ci_find_tools.py @@ -4,14 +4,22 @@ import click from planemo import options -from planemo.ci import filter_paths, print_path_list +from planemo.ci import ( + filter_paths, + group_paths, + print_path_list +) from planemo.cli import command_function -from planemo.tools import is_tool_load_error, yield_tool_sources_on_paths +from planemo.tools import ( + is_tool_load_error, + yield_tool_sources_on_paths +) @click.command('ci_find_tools') @options.shed_project_arg() @options.ci_find_options() +@options.ci_group_tools_option() @command_function def cli(ctx, paths, **kwds): """Find all tools in one or more directories. @@ -26,4 +34,6 @@ def cli(ctx, paths, **kwds): tool_paths.append(tool_path) paths = filter_paths(ctx, tool_paths, path_type="file", **kwds) + if kwds.get('group_tools', False): + paths = group_paths(paths) print_path_list(paths, **kwds) diff --git a/planemo/options.py b/planemo/options.py index 9038d75e3..32da4601e 100644 --- a/planemo/options.py +++ b/planemo/options.py @@ -1602,6 +1602,14 @@ def ci_chunk_count_option(): ) +def ci_group_tools_option(): + return planemo_option( + "--group_tools", + is_flag=True, + help="Group tools of the same repository on a single line." + ) + + def ci_chunk_option(): return planemo_option( "--chunk",