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

import typing
import pathlib
from styxdefs import *

SET_MAP_NAMES_METADATA = Metadata(
    id="7f2099c8418ca1e3fe54b4ccfa0b3990d98a392d.boutiques",
    name="set-map-names",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


SetMapNamesMapParameters = typing.TypedDict('SetMapNamesMapParameters', {
    "@type": typing.NotRequired[typing.Literal["map"]],
    "index": int,
    "new_name": str,
})
SetMapNamesMapParametersTagged = typing.TypedDict('SetMapNamesMapParametersTagged', {
    "@type": typing.Literal["map"],
    "index": int,
    "new_name": str,
})


SetMapNamesParameters = typing.TypedDict('SetMapNamesParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/set-map-names"]],
    "data_file": str,
    "opt_name_file_file": typing.NotRequired[str | None],
    "opt_from_data_file_file": typing.NotRequired[str | None],
    "map": typing.NotRequired[list[SetMapNamesMapParameters] | None],
})
SetMapNamesParametersTagged = typing.TypedDict('SetMapNamesParametersTagged', {
    "@type": typing.Literal["workbench/set-map-names"],
    "data_file": str,
    "opt_name_file_file": typing.NotRequired[str | None],
    "opt_from_data_file_file": typing.NotRequired[str | None],
    "map": typing.NotRequired[list[SetMapNamesMapParameters] | None],
})


def set_map_names_map_params(
    index: int,
    new_name: str,
) -> SetMapNamesMapParametersTagged:
    """
    Build parameters.
    
    Args:
        index: the map index to change the name of.
        new_name: the name to set for the map.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "map",
        "index": index,
        "new_name": new_name,
    }
    return params


def set_map_names_map_cargs(
    params: SetMapNamesMapParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("-map")
    cargs.append(str(params.get("index", None)))
    cargs.append(params.get("new_name", None))
    return cargs


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


def set_map_names_params(
    data_file: str,
    opt_name_file_file: str | None = None,
    opt_from_data_file_file: str | None = None,
    map_: list[SetMapNamesMapParameters] | None = None,
) -> SetMapNamesParametersTagged:
    """
    Build parameters.
    
    Args:
        data_file: the file to set the map names of.
        opt_name_file_file: use a text file to replace all map names: text file\
            containing map names, one per line.
        opt_from_data_file_file: use the map names from another data file: a\
            data file with the same number of maps.
        map_: specify a map to set the name of.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/set-map-names",
        "data_file": data_file,
    }
    if opt_name_file_file is not None:
        params["opt_name_file_file"] = opt_name_file_file
    if opt_from_data_file_file is not None:
        params["opt_from_data_file_file"] = opt_from_data_file_file
    if map_ is not None:
        params["map"] = map_
    return params


def set_map_names_cargs(
    params: SetMapNamesParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("wb_command")
    cargs.append("-set-map-names")
    cargs.append(params.get("data_file", None))
    if params.get("opt_name_file_file", None) is not None:
        cargs.extend([
            "-name-file",
            params.get("opt_name_file_file", None)
        ])
    if params.get("opt_from_data_file_file", None) is not None:
        cargs.extend([
            "-from-data-file",
            params.get("opt_from_data_file_file", None)
        ])
    if params.get("map", None) is not None:
        cargs.extend([a for c in [set_map_names_map_cargs(s, execution) for s in params.get("map", None)] for a in c])
    return cargs


def set_map_names_outputs(
    params: SetMapNamesParameters,
    execution: Execution,
) -> SetMapNamesOutputs:
    """
    Build outputs object containing output file paths and possibly stdout/stderr.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Outputs object.
    """
    ret = SetMapNamesOutputs(
        root=execution.output_file("."),
    )
    return ret


def set_map_names_execute(
    params: SetMapNamesParameters,
    runner: Runner | None = None,
) -> SetMapNamesOutputs:
    """
    set-map-names
    
    Set the name of one or more maps in a file.
    
    Sets the name of one or more maps for metric, shape, label, volume, cifti
    scalar or cifti label files. You must specify either -name-file, or
    -from-data-file, or at least one -map option. The three option types are
    mutually exclusive.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SetMapNamesOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SET_MAP_NAMES_METADATA)
    params = execution.params(params)
    cargs = set_map_names_cargs(params, execution)
    ret = set_map_names_outputs(params, execution)
    execution.run(cargs)
    return ret


def set_map_names(
    data_file: str,
    opt_name_file_file: str | None = None,
    opt_from_data_file_file: str | None = None,
    map_: list[SetMapNamesMapParameters] | None = None,
    runner: Runner | None = None,
) -> SetMapNamesOutputs:
    """
    set-map-names
    
    Set the name of one or more maps in a file.
    
    Sets the name of one or more maps for metric, shape, label, volume, cifti
    scalar or cifti label files. You must specify either -name-file, or
    -from-data-file, or at least one -map option. The three option types are
    mutually exclusive.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        data_file: the file to set the map names of.
        opt_name_file_file: use a text file to replace all map names: text file\
            containing map names, one per line.
        opt_from_data_file_file: use the map names from another data file: a\
            data file with the same number of maps.
        map_: specify a map to set the name of.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SetMapNamesOutputs`).
    """
    params = set_map_names_params(
        data_file=data_file,
        opt_name_file_file=opt_name_file_file,
        opt_from_data_file_file=opt_from_data_file_file,
        map_=map_,
    )
    return set_map_names_execute(params, runner)


__all__ = [
    "SET_MAP_NAMES_METADATA",
    "SetMapNamesOutputs",
    "set_map_names",
    "set_map_names_execute",
    "set_map_names_map_params",
    "set_map_names_params",
]
