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

import typing
import pathlib
from styxdefs import *

SCENE_FILE_RELOCATE_METADATA = Metadata(
    id="cce9293384c531d31f6ab6adfc95c967b2740fd1.workbench",
    name="scene-file-relocate",
    package="workbench",
    container_image_tag="nx10x/workbench:2.1.0",
)


_SceneFileRelocateParamsDictNoTag = typing.TypedDict('_SceneFileRelocateParamsDictNoTag', {
    "input-scene": str,
    "output-scene": str,
})
SceneFileRelocateParamsDictTagged = typing.TypedDict('SceneFileRelocateParamsDictTagged', {
    "@type": typing.Literal["workbench/scene-file-relocate"],
    "input-scene": str,
    "output-scene": str,
})
SceneFileRelocateParamsDict = _SceneFileRelocateParamsDictNoTag | SceneFileRelocateParamsDictTagged


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


def scene_file_relocate_params(
    input_scene: str,
    output_scene: str,
) -> SceneFileRelocateParamsDictTagged:
    """
    Build parameters.
    
    Args:
        input_scene: the scene file to use.
        output_scene: output - the new scene file to create.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/scene-file-relocate",
        "input-scene": input_scene,
        "output-scene": output_scene,
    }
    return params


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


def scene_file_relocate_cargs(
    params: SceneFileRelocateParamsDict,
    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",
        "-scene-file-relocate"
    ])
    cargs.append(params.get("input-scene", None))
    cargs.append(params.get("output-scene", None))
    return cargs


def scene_file_relocate_outputs(
    params: SceneFileRelocateParamsDict,
    execution: Execution,
) -> SceneFileRelocateOutputs:
    """
    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 = SceneFileRelocateOutputs(
        root=execution.output_file("."),
    )
    return ret


def scene_file_relocate_execute(
    params: SceneFileRelocateParamsDict,
    runner: Runner | None = None,
) -> SceneFileRelocateOutputs:
    """
    RECREATE SCENE FILE IN NEW LOCATION.
    
    Scene files contain internal relative paths, such that moving or copying a
    scene file will cause it to lose track of the files it refers to. This
    command makes a modified copy of the scene file, changing the relative paths
    to refer to the new relative locations of the files.
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SceneFileRelocateOutputs`).
    """
    scene_file_relocate_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(SCENE_FILE_RELOCATE_METADATA)
    params = execution.params(params)
    cargs = scene_file_relocate_cargs(params, execution)
    ret = scene_file_relocate_outputs(params, execution)
    execution.run(cargs)
    return ret


def scene_file_relocate(
    input_scene: str,
    output_scene: str,
    runner: Runner | None = None,
) -> SceneFileRelocateOutputs:
    """
    RECREATE SCENE FILE IN NEW LOCATION.
    
    Scene files contain internal relative paths, such that moving or copying a
    scene file will cause it to lose track of the files it refers to. This
    command makes a modified copy of the scene file, changing the relative paths
    to refer to the new relative locations of the files.
    
    Args:
        input_scene: the scene file to use.
        output_scene: output - the new scene file to create.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SceneFileRelocateOutputs`).
    """
    params = scene_file_relocate_params(
        input_scene=input_scene,
        output_scene=output_scene,
    )
    return scene_file_relocate_execute(params, runner)


__all__ = [
    "SCENE_FILE_RELOCATE_METADATA",
    "SceneFileRelocateOutputs",
    "SceneFileRelocateParamsDict",
    "SceneFileRelocateParamsDictTagged",
    "scene_file_relocate",
    "scene_file_relocate_execute",
    "scene_file_relocate_params",
]
