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

import typing
import pathlib
from styxdefs import *

ZIP_SCENE_FILE_METADATA = Metadata(
    id="85d5fb1af707c34c6db735360187816616cc1dda.boutiques",
    name="zip-scene-file",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


ZipSceneFileParameters = typing.TypedDict('ZipSceneFileParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/zip-scene-file"]],
    "scene_file": str,
    "extract_folder": str,
    "zip_file": str,
    "opt_base_dir_directory": typing.NotRequired[str | None],
    "opt_skip_missing": bool,
    "opt_write_scene_file": bool,
})
ZipSceneFileParametersTagged = typing.TypedDict('ZipSceneFileParametersTagged', {
    "@type": typing.Literal["workbench/zip-scene-file"],
    "scene_file": str,
    "extract_folder": str,
    "zip_file": str,
    "opt_base_dir_directory": typing.NotRequired[str | None],
    "opt_skip_missing": bool,
    "opt_write_scene_file": bool,
})


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


def zip_scene_file_params(
    scene_file: str,
    extract_folder: str,
    zip_file: str,
    opt_base_dir_directory: str | None = None,
    opt_skip_missing: bool = False,
    opt_write_scene_file: bool = False,
) -> ZipSceneFileParametersTagged:
    """
    Build parameters.
    
    Args:
        scene_file: the scene file to make the zip file from.
        extract_folder: the name of the folder created when the zip file is\
            unzipped.
        zip_file: out - the zip file that will be created.
        opt_base_dir_directory: specify a directory that all data files are\
            somewhere within, this will become the root of the zipfile's directory\
            structure: the directory.
        opt_skip_missing: any missing files will generate only warnings, and\
            the zip file will be created anyway.
        opt_write_scene_file: rewrite the scene file before zipping, to store a\
            new base path or fix extra '..'s in paths that might break.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/zip-scene-file",
        "scene_file": scene_file,
        "extract_folder": extract_folder,
        "zip_file": zip_file,
        "opt_skip_missing": opt_skip_missing,
        "opt_write_scene_file": opt_write_scene_file,
    }
    if opt_base_dir_directory is not None:
        params["opt_base_dir_directory"] = opt_base_dir_directory
    return params


def zip_scene_file_cargs(
    params: ZipSceneFileParameters,
    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.append("wb_command")
    cargs.append("-zip-scene-file")
    cargs.append(params.get("scene_file", None))
    cargs.append(params.get("extract_folder", None))
    cargs.append(params.get("zip_file", None))
    if params.get("opt_base_dir_directory", None) is not None:
        cargs.extend([
            "-base-dir",
            params.get("opt_base_dir_directory", None)
        ])
    if params.get("opt_skip_missing", False):
        cargs.append("-skip-missing")
    if params.get("opt_write_scene_file", False):
        cargs.append("-write-scene-file")
    return cargs


def zip_scene_file_outputs(
    params: ZipSceneFileParameters,
    execution: Execution,
) -> ZipSceneFileOutputs:
    """
    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 = ZipSceneFileOutputs(
        root=execution.output_file("."),
    )
    return ret


def zip_scene_file_execute(
    params: ZipSceneFileParameters,
    runner: Runner | None = None,
) -> ZipSceneFileOutputs:
    """
    zip-scene-file
    
    Zip a scene file and its data files.
    
    If zip-file already exists, it will be overwritten. If -base-dir is not
    specified, the base directory will be automatically set to the lowest level
    directory containing all files. The scene file must contain only relative
    paths, and no data files may be outside the base directory.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `ZipSceneFileOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(ZIP_SCENE_FILE_METADATA)
    params = execution.params(params)
    cargs = zip_scene_file_cargs(params, execution)
    ret = zip_scene_file_outputs(params, execution)
    execution.run(cargs)
    return ret


def zip_scene_file(
    scene_file: str,
    extract_folder: str,
    zip_file: str,
    opt_base_dir_directory: str | None = None,
    opt_skip_missing: bool = False,
    opt_write_scene_file: bool = False,
    runner: Runner | None = None,
) -> ZipSceneFileOutputs:
    """
    zip-scene-file
    
    Zip a scene file and its data files.
    
    If zip-file already exists, it will be overwritten. If -base-dir is not
    specified, the base directory will be automatically set to the lowest level
    directory containing all files. The scene file must contain only relative
    paths, and no data files may be outside the base directory.
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        scene_file: the scene file to make the zip file from.
        extract_folder: the name of the folder created when the zip file is\
            unzipped.
        zip_file: out - the zip file that will be created.
        opt_base_dir_directory: specify a directory that all data files are\
            somewhere within, this will become the root of the zipfile's directory\
            structure: the directory.
        opt_skip_missing: any missing files will generate only warnings, and\
            the zip file will be created anyway.
        opt_write_scene_file: rewrite the scene file before zipping, to store a\
            new base path or fix extra '..'s in paths that might break.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `ZipSceneFileOutputs`).
    """
    params = zip_scene_file_params(
        scene_file=scene_file,
        extract_folder=extract_folder,
        zip_file=zip_file,
        opt_base_dir_directory=opt_base_dir_directory,
        opt_skip_missing=opt_skip_missing,
        opt_write_scene_file=opt_write_scene_file,
    )
    return zip_scene_file_execute(params, runner)


__all__ = [
    "ZIP_SCENE_FILE_METADATA",
    "ZipSceneFileOutputs",
    "zip_scene_file",
    "zip_scene_file_execute",
    "zip_scene_file_params",
]
