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

import typing
import pathlib
from styxdefs import *
import dataclasses

ANALYZE_TRACE_METADATA = Metadata(
    id="3d880a6da4a3639545433e9f6739d09c2df6cf76.boutiques",
    name="AnalyzeTrace",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class AnalyzeTraceOutputs(typing.NamedTuple):
    """
    Output object returned when calling `analyze_trace(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""


def analyze_trace(
    tracefile: InputPathType,
    max_func_lines: int | None = None,
    suma_c: InputPathType | None = None,
    max_err: int | None = None,
    novolreg: bool = False,
    noxform: bool = False,
    setenv: str | None = None,
    trace_: bool = False,
    extreme_trace: bool = False,
    nomall: bool = False,
    yesmall: bool = False,
    runner: Runner | None = None,
) -> AnalyzeTraceOutputs:
    """
    A program to analyze SUMA (and AFNI's perhaps) stack output for functions that
    return with RETURN without bothering to go on the stack.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        tracefile: Trace output file obtained by redirecting the program’s\
            trace output.
        max_func_lines: Set the maximum number of code lines before a function\
            returns. Default is no limit.
        suma_c: FILE is a SUMA_*.c file. It is analyzed for functions that use\
            SUMA_RETURN without ENTRY.
        max_err: Stop after encountering MAX_ERR errors reported in log.\
            Default is 5. Error key terms are: 'Error', 'error', 'corruption'.
        novolreg: Ignore any Rotate, Volreg, Tagalign, or WarpDrive\
            transformations present in the Surface Volume.
        noxform: Same as -novolreg.
        setenv: Set environment variable ENVname to be ENVvalue. Quotes are\
            necessary.
        trace_: Turns on In/Out debug and Memory tracing.
        extreme_trace: Turns on extreme tracing.
        nomall: Turn off memory tracing.
        yesmall: Turn on memory tracing (default).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `AnalyzeTraceOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(ANALYZE_TRACE_METADATA)
    cargs = []
    cargs.append("AnalyzeTrace")
    cargs.append(execution.input_file(tracefile))
    if max_func_lines is not None:
        cargs.extend([
            "-max_func_lines",
            str(max_func_lines)
        ])
    if suma_c is not None:
        cargs.extend([
            "-suma_c",
            execution.input_file(suma_c)
        ])
    if max_err is not None:
        cargs.extend([
            "-max_err",
            str(max_err)
        ])
    if novolreg:
        cargs.append("-novolreg")
    if noxform:
        cargs.append("-noxform")
    if setenv is not None:
        cargs.extend([
            "-setenv",
            setenv
        ])
    if trace_:
        cargs.append("-trace")
    if extreme_trace:
        cargs.append("-TRACE")
    if nomall:
        cargs.append("-nomall")
    if yesmall:
        cargs.append("-yesmall")
    ret = AnalyzeTraceOutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "ANALYZE_TRACE_METADATA",
    "AnalyzeTraceOutputs",
    "analyze_trace",
]
