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

import typing
import pathlib
from styxdefs import *
import dataclasses

WHIRLGIF_METADATA = Metadata(
    id="5014f57fafa702ba3b19014ba3566e92f5e47369.boutiques",
    name="whirlgif",
    package="fsl",
    container_image_tag="brainlife/fsl:6.0.4-patched2",
)


class WhirlgifOutputs(typing.NamedTuple):
    """
    Output object returned when calling `whirlgif(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_file: OutputPathType | None
    """The generated GIF animation"""


def whirlgif(
    input_files: list[InputPathType],
    outfile: InputPathType | None = None,
    loop_count: int | None = None,
    delay_time: int | None = None,
    disp_flag: typing.Literal["none", "back", "prev", "not"] | None = None,
    list_file: InputPathType | None = None,
    runner: Runner | None = None,
) -> WhirlgifOutputs:
    """
    GIF animation tool.
    
    Author: FMRIB Analysis Group, University of Oxford
    
    URL: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki
    
    Args:
        input_files: Input image files for the animation.
        outfile: Specify the output file.
        loop_count: Specify the loop count for the animation.
        delay_time: Specify the delay time between frames.
        disp_flag: Specify the disposal method for frames.
        list_file: Input list file containing names of images to be used for\
            animation.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `WhirlgifOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(WHIRLGIF_METADATA)
    cargs = []
    cargs.append("whirlgif")
    if outfile is not None:
        cargs.extend([
            "-o",
            execution.input_file(outfile)
        ])
    if loop_count is not None:
        cargs.extend([
            "-loop",
            str(loop_count)
        ])
    if delay_time is not None:
        cargs.extend([
            "-time",
            str(delay_time)
        ])
    if disp_flag is not None:
        cargs.extend([
            "-disp",
            disp_flag
        ])
    if list_file is not None:
        cargs.extend([
            "-i",
            execution.input_file(list_file)
        ])
    cargs.extend([execution.input_file(f) for f in input_files])
    ret = WhirlgifOutputs(
        root=execution.output_file("."),
        output_file=execution.output_file(pathlib.Path(outfile).name) if (outfile is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "WHIRLGIF_METADATA",
    "WhirlgifOutputs",
    "whirlgif",
]
