# This file was auto generated by Styx.
# Do not edit this file directly.

import typing
import pathlib
from styxdefs import *
import dataclasses

APSEARCH_METADATA = Metadata(
    id="daa8fa19d4d15fe37e1fd44af2f41bbb1e0649d7.boutiques",
    name="apsearch",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class ApsearchOutputs(typing.NamedTuple):
    """
    Output object returned when calling `apsearch(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_file: OutputPathType | None
    """File containing search results"""


def apsearch(
    search_term: str,
    file_output: InputPathType | None = None,
    verbose: bool = False,
    runner: Runner | None = None,
) -> ApsearchOutputs:
    """
    A tool for searching applications.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        search_term: Term to search.
        file_output: File to save the search results.
        verbose: Print detailed information during search.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `ApsearchOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(APSEARCH_METADATA)
    cargs = []
    cargs.append("apsearch")
    cargs.append(search_term)
    if file_output is not None:
        cargs.append(execution.input_file(file_output))
    if verbose:
        cargs.append("-v")
    ret = ApsearchOutputs(
        root=execution.output_file("."),
        output_file=execution.output_file(pathlib.Path(file_output).name) if (file_output is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "APSEARCH_METADATA",
    "ApsearchOutputs",
    "apsearch",
]
