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

import typing
import pathlib
from styxdefs import *

VOLUME_COPY_EXTENSIONS_METADATA = Metadata(
    id="ce53186c774fd3df17402a86376908e43ca4e439.workbench",
    name="volume-copy-extensions",
    package="workbench",
    container_image_tag="nx10x/workbench:2.1.0",
)


_VolumeCopyExtensionsParamsDictNoTag = typing.TypedDict('_VolumeCopyExtensionsParamsDictNoTag', {
    "data-volume": InputPathType,
    "extension-volume": InputPathType,
    "volume-out": str,
    "drop-unknown": bool,
})
VolumeCopyExtensionsParamsDictTagged = typing.TypedDict('VolumeCopyExtensionsParamsDictTagged', {
    "@type": typing.Literal["workbench/volume-copy-extensions"],
    "data-volume": InputPathType,
    "extension-volume": InputPathType,
    "volume-out": str,
    "drop-unknown": bool,
})
VolumeCopyExtensionsParamsDict = _VolumeCopyExtensionsParamsDictNoTag | VolumeCopyExtensionsParamsDictTagged


class VolumeCopyExtensionsOutputs(typing.NamedTuple):
    """
    Output object returned when calling `VolumeCopyExtensionsParamsDict(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    volume_out: OutputPathType
    """the output volume"""


def volume_copy_extensions_params(
    data_volume: InputPathType,
    extension_volume: InputPathType,
    volume_out: str,
    drop_unknown: bool = False,
) -> VolumeCopyExtensionsParamsDictTagged:
    """
    Build parameters.
    
    Args:
        data_volume: the volume file containing the voxel data to use.
        extension_volume: the volume file containing the extensions to use.
        volume_out: the output volume.
        drop_unknown: don't copy extensions that workbench doesn't understand.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/volume-copy-extensions",
        "data-volume": data_volume,
        "extension-volume": extension_volume,
        "volume-out": volume_out,
        "drop-unknown": drop_unknown,
    }
    return params


def volume_copy_extensions_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `VolumeCopyExtensionsParamsDict` 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("data-volume", None) is None:
        raise StyxValidationError("`data-volume` must not be None")
    if not isinstance(params["data-volume"], (pathlib.Path, str)):
        raise StyxValidationError(f'`data-volume` has the wrong type: Received `{type(params.get("data-volume", None))}` expected `InputPathType`')
    if params.get("extension-volume", None) is None:
        raise StyxValidationError("`extension-volume` must not be None")
    if not isinstance(params["extension-volume"], (pathlib.Path, str)):
        raise StyxValidationError(f'`extension-volume` has the wrong type: Received `{type(params.get("extension-volume", None))}` expected `InputPathType`')
    if params.get("volume-out", None) is None:
        raise StyxValidationError("`volume-out` must not be None")
    if not isinstance(params["volume-out"], str):
        raise StyxValidationError(f'`volume-out` has the wrong type: Received `{type(params.get("volume-out", None))}` expected `str`')
    if params.get("drop-unknown", False) is None:
        raise StyxValidationError("`drop-unknown` must not be None")
    if not isinstance(params["drop-unknown"], bool):
        raise StyxValidationError(f'`drop-unknown` has the wrong type: Received `{type(params.get("drop-unknown", False))}` expected `bool`')


def volume_copy_extensions_cargs(
    params: VolumeCopyExtensionsParamsDict,
    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",
        "-volume-copy-extensions"
    ])
    cargs.append(execution.input_file(params.get("data-volume", None)))
    cargs.append(execution.input_file(params.get("extension-volume", None)))
    cargs.append(params.get("volume-out", None))
    if params.get("drop-unknown", False):
        cargs.append("-drop-unknown")
    return cargs


def volume_copy_extensions_outputs(
    params: VolumeCopyExtensionsParamsDict,
    execution: Execution,
) -> VolumeCopyExtensionsOutputs:
    """
    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 = VolumeCopyExtensionsOutputs(
        root=execution.output_file("."),
        volume_out=execution.output_file(params.get("volume-out", None)),
    )
    return ret


def volume_copy_extensions_execute(
    params: VolumeCopyExtensionsParamsDict,
    runner: Runner | None = None,
) -> VolumeCopyExtensionsOutputs:
    """
    COPY EXTENDED DATA TO ANOTHER VOLUME FILE.
    
    This command copies the information in a volume file that isn't a critical
    part of the standard header or data matrix, e.g. map names, palette
    settings, label tables. If -drop-unknown is not specified, it also copies
    similar kinds of information set by other software.
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `VolumeCopyExtensionsOutputs`).
    """
    volume_copy_extensions_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(VOLUME_COPY_EXTENSIONS_METADATA)
    params = execution.params(params)
    cargs = volume_copy_extensions_cargs(params, execution)
    ret = volume_copy_extensions_outputs(params, execution)
    execution.run(cargs)
    return ret


def volume_copy_extensions(
    data_volume: InputPathType,
    extension_volume: InputPathType,
    volume_out: str,
    drop_unknown: bool = False,
    runner: Runner | None = None,
) -> VolumeCopyExtensionsOutputs:
    """
    COPY EXTENDED DATA TO ANOTHER VOLUME FILE.
    
    This command copies the information in a volume file that isn't a critical
    part of the standard header or data matrix, e.g. map names, palette
    settings, label tables. If -drop-unknown is not specified, it also copies
    similar kinds of information set by other software.
    
    Args:
        data_volume: the volume file containing the voxel data to use.
        extension_volume: the volume file containing the extensions to use.
        volume_out: the output volume.
        drop_unknown: don't copy extensions that workbench doesn't understand.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `VolumeCopyExtensionsOutputs`).
    """
    params = volume_copy_extensions_params(
        data_volume=data_volume,
        extension_volume=extension_volume,
        volume_out=volume_out,
        drop_unknown=drop_unknown,
    )
    return volume_copy_extensions_execute(params, runner)


__all__ = [
    "VOLUME_COPY_EXTENSIONS_METADATA",
    "VolumeCopyExtensionsOutputs",
    "VolumeCopyExtensionsParamsDict",
    "VolumeCopyExtensionsParamsDictTagged",
    "volume_copy_extensions",
    "volume_copy_extensions_execute",
    "volume_copy_extensions_params",
]
