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

import typing
import pathlib
from styxdefs import *
import dataclasses

FS_TIME_METADATA = Metadata(
    id="ca61b3d7c09ab70471b0b19e87ec76f60e282835.boutiques",
    name="fs_time",
    package="freesurfer",
    container_image_tag="freesurfer/freesurfer:7.4.1",
)


class FsTimeOutputs(typing.NamedTuple):
    """
    Output object returned when calling `fs_time(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    resource_output: OutputPathType | None
    """File containing resource usage information."""


def fs_time(
    command: str,
    output_file: str | None = None,
    key: str | None = None,
    load_avg: bool = False,
    args: list[str] | None = None,
    runner: Runner | None = None,
) -> FsTimeOutputs:
    """
    A frontend for the unix /usr/bin/time program to track resource usage by a
    process.
    
    Author: FreeSurfer Developers
    
    URL: https://github.com/freesurfer/freesurfer
    
    Args:
        command: The command to be timed with fs_time.
        output_file: Save resource info into output file.
        key: Specify a key for the resource information.
        load_avg: Report on load averages as from uptime.
        args: Arguments for the command.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `FsTimeOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(FS_TIME_METADATA)
    cargs = []
    cargs.append("fs_time")
    if output_file is not None:
        cargs.extend([
            "-o",
            output_file
        ])
    if key is not None:
        cargs.extend([
            "-k",
            key
        ])
    if load_avg:
        cargs.append("-l")
    cargs.append(command)
    if args is not None:
        cargs.extend(args)
    ret = FsTimeOutputs(
        root=execution.output_file("."),
        resource_output=execution.output_file(output_file) if (output_file is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "FS_TIME_METADATA",
    "FsTimeOutputs",
    "fs_time",
]
