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

import typing
import pathlib
from styxdefs import *

METADATA_REMOVE_PROVENANCE_METADATA = Metadata(
    id="e8c16ad9420831ac3f90677352afe3ddc5dcbac7.workbench",
    name="metadata-remove-provenance",
    package="workbench",
    container_image_tag="nx10x/workbench:2.1.0",
)


_MetadataRemoveProvenanceParamsDictNoTag = typing.TypedDict('_MetadataRemoveProvenanceParamsDictNoTag', {
    "input-file": str,
    "output-file": str,
})
MetadataRemoveProvenanceParamsDictTagged = typing.TypedDict('MetadataRemoveProvenanceParamsDictTagged', {
    "@type": typing.Literal["workbench/metadata-remove-provenance"],
    "input-file": str,
    "output-file": str,
})
MetadataRemoveProvenanceParamsDict = _MetadataRemoveProvenanceParamsDictNoTag | MetadataRemoveProvenanceParamsDictTagged


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


def metadata_remove_provenance_params(
    input_file: str,
    output_file: str,
) -> MetadataRemoveProvenanceParamsDictTagged:
    """
    Build parameters.
    
    Args:
        input_file: the file to remove provenance information from.
        output_file: output - the name to save the modified file as.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/metadata-remove-provenance",
        "input-file": input_file,
        "output-file": output_file,
    }
    return params


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


def metadata_remove_provenance_cargs(
    params: MetadataRemoveProvenanceParamsDict,
    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",
        "-metadata-remove-provenance"
    ])
    cargs.append(params.get("input-file", None))
    cargs.append(params.get("output-file", None))
    return cargs


def metadata_remove_provenance_outputs(
    params: MetadataRemoveProvenanceParamsDict,
    execution: Execution,
) -> MetadataRemoveProvenanceOutputs:
    """
    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 = MetadataRemoveProvenanceOutputs(
        root=execution.output_file("."),
    )
    return ret


def metadata_remove_provenance_execute(
    params: MetadataRemoveProvenanceParamsDict,
    runner: Runner | None = None,
) -> MetadataRemoveProvenanceOutputs:
    """
    REMOVE PROVENANCE INFORMATION FROM FILE METADATA.
    
    Removes the provenance metadata fields added by workbench during processing.
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MetadataRemoveProvenanceOutputs`).
    """
    metadata_remove_provenance_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(METADATA_REMOVE_PROVENANCE_METADATA)
    params = execution.params(params)
    cargs = metadata_remove_provenance_cargs(params, execution)
    ret = metadata_remove_provenance_outputs(params, execution)
    execution.run(cargs)
    return ret


def metadata_remove_provenance(
    input_file: str,
    output_file: str,
    runner: Runner | None = None,
) -> MetadataRemoveProvenanceOutputs:
    """
    REMOVE PROVENANCE INFORMATION FROM FILE METADATA.
    
    Removes the provenance metadata fields added by workbench during processing.
    
    Args:
        input_file: the file to remove provenance information from.
        output_file: output - the name to save the modified file as.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `MetadataRemoveProvenanceOutputs`).
    """
    params = metadata_remove_provenance_params(
        input_file=input_file,
        output_file=output_file,
    )
    return metadata_remove_provenance_execute(params, runner)


__all__ = [
    "METADATA_REMOVE_PROVENANCE_METADATA",
    "MetadataRemoveProvenanceOutputs",
    "MetadataRemoveProvenanceParamsDict",
    "MetadataRemoveProvenanceParamsDictTagged",
    "metadata_remove_provenance",
    "metadata_remove_provenance_execute",
    "metadata_remove_provenance_params",
]
