view env/lib/python3.9/site-packages/planemo/commands/cmd_conda_search.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 ``conda_search`` command."""
from __future__ import print_function

import click
import packaging.version

from planemo import options
from planemo.cli import command_function
from planemo.conda import build_conda_context

VERSION_4_DOT_4 = packaging.version.Version("4.4")


@click.command('conda_search')
@options.conda_target_options(include_local=False)
@click.argument(
    "term",
    metavar="TERM",
    type=str,
    nargs=1,
)
@command_function
def cli(ctx, term, **kwds):
    """Perform conda search with Planemo's conda.

    Implicitly adds channels Planemo is configured with.
    """
    conda_context = build_conda_context(ctx, handle_auto_init=True, **kwds)
    # Handle CLI interface change for conda search in 4.5.
    #  xref: https://github.com/conda/conda/pull/5597/files
    if conda_context.conda_version >= VERSION_4_DOT_4:
        term = "*%s*" % term
    args = conda_context._override_channels_args + [term]
    conda_context.exec_command("search", args)