view env/lib/python3.9/site-packages/planemo/commands/cmd_ci_find_tools.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
line wrap: on
line source

"""Module describing the planemo ``ci_find_tools`` command."""
from __future__ import print_function

import click

from planemo import options
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
)


@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.

    Tools can be chunked up, filtered, etc... to build lists of tools to perform
    operations over for continuous integration operations.
    """
    tool_paths = []
    for (tool_path, tool_source) in yield_tool_sources_on_paths(ctx, paths, recursive=True):
        if is_tool_load_error(tool_source):
            continue
        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)