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

import typing
import pathlib
from styxdefs import *

SURFACE_INFORMATION_METADATA = Metadata(
    id="87b1b891daeb7b0feeaa4cf02501f4785ccf44ce.workbench",
    name="surface-information",
    package="workbench",
    container_image_tag="nx10x/workbench:2.1.0",
)


_SurfaceInformationParamsDictNoTag = typing.TypedDict('_SurfaceInformationParamsDictNoTag', {
    "Surface File": InputPathType,
})
SurfaceInformationParamsDictTagged = typing.TypedDict('SurfaceInformationParamsDictTagged', {
    "@type": typing.Literal["workbench/surface-information"],
    "Surface File": InputPathType,
})
SurfaceInformationParamsDict = _SurfaceInformationParamsDictNoTag | SurfaceInformationParamsDictTagged


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


def surface_information_params(
    surface_file: InputPathType,
) -> SurfaceInformationParamsDictTagged:
    """
    Build parameters.
    
    Args:
        surface_file: Surface for which information is displayed.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/surface-information",
        "Surface File": surface_file,
    }
    return params


def surface_information_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `SurfaceInformationParamsDict` 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 File", None) is None:
        raise StyxValidationError("`Surface File` must not be None")
    if not isinstance(params["Surface File"], (pathlib.Path, str)):
        raise StyxValidationError(f'`Surface File` has the wrong type: Received `{type(params.get("Surface File", None))}` expected `InputPathType`')


def surface_information_cargs(
    params: SurfaceInformationParamsDict,
    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-information"
    ])
    cargs.append(execution.input_file(params.get("Surface File", None)))
    return cargs


def surface_information_outputs(
    params: SurfaceInformationParamsDict,
    execution: Execution,
) -> SurfaceInformationOutputs:
    """
    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 = SurfaceInformationOutputs(
        root=execution.output_file("."),
    )
    return ret


def surface_information_execute(
    params: SurfaceInformationParamsDict,
    runner: Runner | None = None,
) -> SurfaceInformationOutputs:
    """
    DISPLAY INFORMATION ABOUT A SURFACE.
    
    Information about surface is displayed including vertices,
    triangles, bounding box, and spacing.
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceInformationOutputs`).
    """
    surface_information_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(SURFACE_INFORMATION_METADATA)
    params = execution.params(params)
    cargs = surface_information_cargs(params, execution)
    ret = surface_information_outputs(params, execution)
    execution.run(cargs)
    return ret


def surface_information(
    surface_file: InputPathType,
    runner: Runner | None = None,
) -> SurfaceInformationOutputs:
    """
    DISPLAY INFORMATION ABOUT A SURFACE.
    
    Information about surface is displayed including vertices,
    triangles, bounding box, and spacing.
    
    Args:
        surface_file: Surface for which information is displayed.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceInformationOutputs`).
    """
    params = surface_information_params(
        surface_file=surface_file,
    )
    return surface_information_execute(params, runner)


__all__ = [
    "SURFACE_INFORMATION_METADATA",
    "SurfaceInformationOutputs",
    "SurfaceInformationParamsDict",
    "SurfaceInformationParamsDictTagged",
    "surface_information",
    "surface_information_execute",
    "surface_information_params",
]
