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

import typing
import pathlib
from styxdefs import *

SURFACE_SET_COORDINATES_METADATA = Metadata(
    id="6300d8d0bb2424f11e6f8bc0f67e98142564cdff.workbench",
    name="surface-set-coordinates",
    package="workbench",
    container_image_tag="nx10x/workbench:2.1.0",
)


_SurfaceSetCoordinatesParamsDictNoTag = typing.TypedDict('_SurfaceSetCoordinatesParamsDictNoTag', {
    "surface-in": InputPathType,
    "coord-metric": InputPathType,
    "surface-out": str,
})
SurfaceSetCoordinatesParamsDictTagged = typing.TypedDict('SurfaceSetCoordinatesParamsDictTagged', {
    "@type": typing.Literal["workbench/surface-set-coordinates"],
    "surface-in": InputPathType,
    "coord-metric": InputPathType,
    "surface-out": str,
})
SurfaceSetCoordinatesParamsDict = _SurfaceSetCoordinatesParamsDictNoTag | SurfaceSetCoordinatesParamsDictTagged


class SurfaceSetCoordinatesOutputs(typing.NamedTuple):
    """
    Output object returned when calling `SurfaceSetCoordinatesParamsDict(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    surface_out: OutputPathType
    """the new surface"""


def surface_set_coordinates_params(
    surface_in: InputPathType,
    coord_metric: InputPathType,
    surface_out: str,
) -> SurfaceSetCoordinatesParamsDictTagged:
    """
    Build parameters.
    
    Args:
        surface_in: the surface to use for the topology.
        coord_metric: the new coordinates, as a 3-column metric file.
        surface_out: the new surface.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/surface-set-coordinates",
        "surface-in": surface_in,
        "coord-metric": coord_metric,
        "surface-out": surface_out,
    }
    return params


def surface_set_coordinates_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `SurfaceSetCoordinatesParamsDict` object.
    
    Args:
        params: The parameters object to validate.
    """
    if params is None or not isinstance(params, dict):
        raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
    if params.get("surface-in", None) is None:
        raise StyxValidationError("`surface-in` must not be None")
    if not isinstance(params["surface-in"], (pathlib.Path, str)):
        raise StyxValidationError(f'`surface-in` has the wrong type: Received `{type(params.get("surface-in", None))}` expected `InputPathType`')
    if params.get("coord-metric", None) is None:
        raise StyxValidationError("`coord-metric` must not be None")
    if not isinstance(params["coord-metric"], (pathlib.Path, str)):
        raise StyxValidationError(f'`coord-metric` has the wrong type: Received `{type(params.get("coord-metric", None))}` expected `InputPathType`')
    if params.get("surface-out", None) is None:
        raise StyxValidationError("`surface-out` must not be None")
    if not isinstance(params["surface-out"], str):
        raise StyxValidationError(f'`surface-out` has the wrong type: Received `{type(params.get("surface-out", None))}` expected `str`')


def surface_set_coordinates_cargs(
    params: SurfaceSetCoordinatesParamsDict,
    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.extend([
        "wb_command",
        "-surface-set-coordinates"
    ])
    cargs.append(execution.input_file(params.get("surface-in", None)))
    cargs.append(execution.input_file(params.get("coord-metric", None)))
    cargs.append(params.get("surface-out", None))
    return cargs


def surface_set_coordinates_outputs(
    params: SurfaceSetCoordinatesParamsDict,
    execution: Execution,
) -> SurfaceSetCoordinatesOutputs:
    """
    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 = SurfaceSetCoordinatesOutputs(
        root=execution.output_file("."),
        surface_out=execution.output_file(params.get("surface-out", None)),
    )
    return ret


def surface_set_coordinates_execute(
    params: SurfaceSetCoordinatesParamsDict,
    runner: Runner | None = None,
) -> SurfaceSetCoordinatesOutputs:
    """
    MODIFY COORDINATES OF A SURFACE.
    
    Takes the topology from an existing surface file, and uses values from a
    metric file as coordinates to construct a new surface file.
    
    See -surface-coordinates-to-metric for how to get surface coordinates as a
    metric file, such that you can then modify them via metric commands, etc.
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceSetCoordinatesOutputs`).
    """
    surface_set_coordinates_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(SURFACE_SET_COORDINATES_METADATA)
    params = execution.params(params)
    cargs = surface_set_coordinates_cargs(params, execution)
    ret = surface_set_coordinates_outputs(params, execution)
    execution.run(cargs)
    return ret


def surface_set_coordinates(
    surface_in: InputPathType,
    coord_metric: InputPathType,
    surface_out: str,
    runner: Runner | None = None,
) -> SurfaceSetCoordinatesOutputs:
    """
    MODIFY COORDINATES OF A SURFACE.
    
    Takes the topology from an existing surface file, and uses values from a
    metric file as coordinates to construct a new surface file.
    
    See -surface-coordinates-to-metric for how to get surface coordinates as a
    metric file, such that you can then modify them via metric commands, etc.
    
    Args:
        surface_in: the surface to use for the topology.
        coord_metric: the new coordinates, as a 3-column metric file.
        surface_out: the new surface.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceSetCoordinatesOutputs`).
    """
    params = surface_set_coordinates_params(
        surface_in=surface_in,
        coord_metric=coord_metric,
        surface_out=surface_out,
    )
    return surface_set_coordinates_execute(params, runner)


__all__ = [
    "SURFACE_SET_COORDINATES_METADATA",
    "SurfaceSetCoordinatesOutputs",
    "SurfaceSetCoordinatesParamsDict",
    "SurfaceSetCoordinatesParamsDictTagged",
    "surface_set_coordinates",
    "surface_set_coordinates_execute",
    "surface_set_coordinates_params",
]
