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

import typing
import pathlib
from styxdefs import *
import dataclasses

AFNI_BATCH_R_METADATA = Metadata(
    id="58eaf579cadf280b0a770416bff7f89183ec4670.boutiques",
    name="AFNI_Batch_R",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


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


def afni_batch_r(
    no_restore: bool = False,
    save_workspace: bool = False,
    no_readline: bool = False,
    vanilla_mode: bool = False,
    help_: bool = False,
    runner: Runner | None = None,
) -> AfniBatchROutputs:
    """
    Batch mode for executing R scripts in the AFNI environment.
    
    Author: AFNI Team
    
    URL: https://afni.nimh.nih.gov/pub/dist/doc/program_help/AFNI_Batch_R.html
    
    Args:
        no_restore: Do not restore anything in the R workspace at startup.
        save_workspace: Save the workspace at the end of the script execution.
        no_readline: Disable reading input from the command line.
        vanilla_mode: Run R without saving the workspace at the end, restoring\
            anything, reading the site file, or acting on startup files.
        help_: Display this help message and exit.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `AfniBatchROutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(AFNI_BATCH_R_METADATA)
    cargs = []
    cargs.append("/opt/afni/src/../install/AFNI_Batch_R")
    cargs.append("R")
    cargs.append("CMD")
    cargs.append("BATCH")
    if no_restore:
        cargs.append("--no-restore")
    if save_workspace:
        cargs.append("--save")
    if no_readline:
        cargs.append("--no-readline")
    if vanilla_mode:
        cargs.append("--vanilla")
    cargs.append("--args")
    if help_:
        cargs.append("-help")
    ret = AfniBatchROutputs(
        root=execution.output_file("."),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "AFNI_BATCH_R_METADATA",
    "AfniBatchROutputs",
    "afni_batch_r",
]
