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

import typing
import pathlib
from styxdefs import *
import dataclasses

EXTRACTTXT_METADATA = Metadata(
    id="48cff102ad59e3a8afc267b63f335c1516c29429.boutiques",
    name="extracttxt",
    package="fsl",
    container_image_tag="brainlife/fsl:6.0.4-patched2",
)


class ExtracttxtOutputs(typing.NamedTuple):
    """
    Output object returned when calling `extracttxt(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_file: OutputPathType
    """Extracted text output file"""


def extracttxt(
    search_word: str,
    file: InputPathType,
    num_trailing_lines: float | None = 0,
    relative_start: float | None = 0,
    runner: Runner | None = None,
) -> ExtracttxtOutputs:
    """
    Extracts text from a file based on a search word.
    
    Author: FMRIB Analysis Group, University of Oxford
    
    URL: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki
    
    Args:
        search_word: The word to search for in the file.
        file: Path to the file where text is to be extracted.
        num_trailing_lines: Number of trailing lines to include after the\
            search word.
        relative_start: Relative start position to begin the search.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `ExtracttxtOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(EXTRACTTXT_METADATA)
    cargs = []
    cargs.append("extracttxt")
    cargs.append(search_word)
    cargs.append(execution.input_file(file))
    if num_trailing_lines is not None:
        cargs.append(str(num_trailing_lines))
    if relative_start is not None:
        cargs.append(str(relative_start))
    ret = ExtracttxtOutputs(
        root=execution.output_file("."),
        output_file=execution.output_file("output.txt"),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "EXTRACTTXT_METADATA",
    "ExtracttxtOutputs",
    "extracttxt",
]
