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

import typing
import pathlib
from styxdefs import *

FILE_INFORMATION_METADATA = Metadata(
    id="c64f1cc09da72b367adf8dd817016952eac8d776.workbench",
    name="file-information",
    package="workbench",
    container_image_tag="nx10x/workbench:2.1.0",
)


_FileInformationOnlyMetadataParamsDictNoTag = typing.TypedDict('_FileInformationOnlyMetadataParamsDictNoTag', {
    "key": typing.NotRequired[str | None],
})
FileInformationOnlyMetadataParamsDictTagged = typing.TypedDict('FileInformationOnlyMetadataParamsDictTagged', {
    "@type": typing.Literal["only-metadata"],
    "key": typing.NotRequired[str | None],
})
FileInformationOnlyMetadataParamsDict = _FileInformationOnlyMetadataParamsDictNoTag | FileInformationOnlyMetadataParamsDictTagged


_FileInformationParamsDictNoTag = typing.TypedDict('_FileInformationParamsDictNoTag', {
    "data-file": str,
    "only-metadata": typing.NotRequired[FileInformationOnlyMetadataParamsDict | None],
    "czi-xml": bool,
    "czi-all-sub-blocks": bool,
    "czi": bool,
    "only-cifti-xml": bool,
    "only-map-names": bool,
    "only-number-of-maps": bool,
    "only-step-interval": bool,
    "no-map-info": bool,
})
FileInformationParamsDictTagged = typing.TypedDict('FileInformationParamsDictTagged', {
    "@type": typing.Literal["workbench/file-information"],
    "data-file": str,
    "only-metadata": typing.NotRequired[FileInformationOnlyMetadataParamsDict | None],
    "czi-xml": bool,
    "czi-all-sub-blocks": bool,
    "czi": bool,
    "only-cifti-xml": bool,
    "only-map-names": bool,
    "only-number-of-maps": bool,
    "only-step-interval": bool,
    "no-map-info": bool,
})
FileInformationParamsDict = _FileInformationParamsDictNoTag | FileInformationParamsDictTagged


def file_information_only_metadata(
    key: str | None = None,
) -> FileInformationOnlyMetadataParamsDictTagged:
    """
    Build parameters.
    
    Args:
        key: only print the metadata for one key, with no formatting\
            \
            the metadata key.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "only-metadata",
    }
    if key is not None:
        params["key"] = key
    return params


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


def file_information_only_metadata_cargs(
    params: FileInformationOnlyMetadataParamsDict,
    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("-only-metadata")
    if params.get("key", None) is not None:
        cargs.extend([
            "-key",
            params.get("key", None)
        ])
    return cargs


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


def file_information_params(
    data_file: str,
    only_metadata: FileInformationOnlyMetadataParamsDict | None = None,
    czi_xml: bool = False,
    czi_all_sub_blocks: bool = False,
    czi: bool = False,
    only_cifti_xml: bool = False,
    only_map_names: bool = False,
    only_number_of_maps: bool = False,
    only_step_interval: bool = False,
    no_map_info: bool = False,
) -> FileInformationParamsDictTagged:
    """
    Build parameters.
    
    Args:
        data_file: data file.
        only_metadata: suppress normal output, print file metadata.
        czi_xml: show XML from CZI file.
        czi_all_sub_blocks: show all sub-blocks in CZI file (may produce long\
            output).
        czi: For a CZI file, show information from the libCZI Info Command\
            instead of the Workbench CZI File.
        only_cifti_xml: suppress normal output, print the cifti xml if the file\
            type has it.
        only_map_names: suppress normal output, print the names of all maps.
        only_number_of_maps: suppress normal output, print the number of maps.
        only_step_interval: suppress normal output, print the interval between\
            maps.
        no_map_info: do not show map information for files that support maps.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/file-information",
        "data-file": data_file,
        "czi-xml": czi_xml,
        "czi-all-sub-blocks": czi_all_sub_blocks,
        "czi": czi,
        "only-cifti-xml": only_cifti_xml,
        "only-map-names": only_map_names,
        "only-number-of-maps": only_number_of_maps,
        "only-step-interval": only_step_interval,
        "no-map-info": no_map_info,
    }
    if only_metadata is not None:
        params["only-metadata"] = only_metadata
    return params


def file_information_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `FileInformationParamsDict` 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-file", None) is None:
        raise StyxValidationError("`data-file` must not be None")
    if not isinstance(params["data-file"], str):
        raise StyxValidationError(f'`data-file` has the wrong type: Received `{type(params.get("data-file", None))}` expected `str`')
    if params.get("only-metadata", None) is not None:
        file_information_only_metadata_validate(params["only-metadata"])
    if params.get("czi-xml", False) is None:
        raise StyxValidationError("`czi-xml` must not be None")
    if not isinstance(params["czi-xml"], bool):
        raise StyxValidationError(f'`czi-xml` has the wrong type: Received `{type(params.get("czi-xml", False))}` expected `bool`')
    if params.get("czi-all-sub-blocks", False) is None:
        raise StyxValidationError("`czi-all-sub-blocks` must not be None")
    if not isinstance(params["czi-all-sub-blocks"], bool):
        raise StyxValidationError(f'`czi-all-sub-blocks` has the wrong type: Received `{type(params.get("czi-all-sub-blocks", False))}` expected `bool`')
    if params.get("czi", False) is None:
        raise StyxValidationError("`czi` must not be None")
    if not isinstance(params["czi"], bool):
        raise StyxValidationError(f'`czi` has the wrong type: Received `{type(params.get("czi", False))}` expected `bool`')
    if params.get("only-cifti-xml", False) is None:
        raise StyxValidationError("`only-cifti-xml` must not be None")
    if not isinstance(params["only-cifti-xml"], bool):
        raise StyxValidationError(f'`only-cifti-xml` has the wrong type: Received `{type(params.get("only-cifti-xml", False))}` expected `bool`')
    if params.get("only-map-names", False) is None:
        raise StyxValidationError("`only-map-names` must not be None")
    if not isinstance(params["only-map-names"], bool):
        raise StyxValidationError(f'`only-map-names` has the wrong type: Received `{type(params.get("only-map-names", False))}` expected `bool`')
    if params.get("only-number-of-maps", False) is None:
        raise StyxValidationError("`only-number-of-maps` must not be None")
    if not isinstance(params["only-number-of-maps"], bool):
        raise StyxValidationError(f'`only-number-of-maps` has the wrong type: Received `{type(params.get("only-number-of-maps", False))}` expected `bool`')
    if params.get("only-step-interval", False) is None:
        raise StyxValidationError("`only-step-interval` must not be None")
    if not isinstance(params["only-step-interval"], bool):
        raise StyxValidationError(f'`only-step-interval` has the wrong type: Received `{type(params.get("only-step-interval", False))}` expected `bool`')
    if params.get("no-map-info", False) is None:
        raise StyxValidationError("`no-map-info` must not be None")
    if not isinstance(params["no-map-info"], bool):
        raise StyxValidationError(f'`no-map-info` has the wrong type: Received `{type(params.get("no-map-info", False))}` expected `bool`')


def file_information_cargs(
    params: FileInformationParamsDict,
    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",
        "-file-information"
    ])
    cargs.append(params.get("data-file", None))
    if params.get("only-metadata", None) is not None:
        cargs.extend(file_information_only_metadata_cargs(params.get("only-metadata", None), execution))
    if params.get("czi-xml", False):
        cargs.append("-czi-xml")
    if params.get("czi-all-sub-blocks", False):
        cargs.append("-czi-all-sub-blocks")
    if params.get("czi", False):
        cargs.append("-czi")
    if params.get("only-cifti-xml", False):
        cargs.append("-only-cifti-xml")
    if params.get("only-map-names", False):
        cargs.append("-only-map-names")
    if params.get("only-number-of-maps", False):
        cargs.append("-only-number-of-maps")
    if params.get("only-step-interval", False):
        cargs.append("-only-step-interval")
    if params.get("no-map-info", False):
        cargs.append("-no-map-info")
    return cargs


def file_information_outputs(
    params: FileInformationParamsDict,
    execution: Execution,
) -> FileInformationOutputs:
    """
    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 = FileInformationOutputs(
        root=execution.output_file("."),
    )
    return ret


def file_information_execute(
    params: FileInformationParamsDict,
    runner: Runner | None = None,
) -> FileInformationOutputs:
    """
    LIST INFORMATION ABOUT A FILE'S CONTENT.
    
    List information about the content of a data file. Only one -only option may
    be specified. The information listed when no -only option is present is
    dependent upon the type of data file.
    
    Library paths:
    /usr/lib/x86_64-linux-gnu/qt5/plugins
    /workspace/source/build/CommandLine
    
    
    File and extensions for reading and writing:
    Annotation: wb_annot
    Annotation Text Substitution: wb_annsub.csv
    Border: border, wb_border
    CIFTI - Dense: dconn.nii
    CIFTI - Dense Label: dlabel.nii
    CIFTI - Dense Parcel: dpconn.nii
    CIFTI - Dense Scalar: dscalar.nii
    CIFTI - Dense Data Series: dtseries.nii
    CIFTI - Fiber Orientations TEMPORARY: fiberTEMP.nii
    CIFTI - Fiber Trajectory TEMPORARY: trajTEMP.wbsparse
    CIFTI - Fiber Trajectory Maps: trajMaps.wbsparse
    CIFTI - Parcel: pconn.nii
    CIFTI - Parcel Dense: pdconn.nii
    CIFTI - Parcel Label: plabel.nii
    CIFTI - Parcel Scalar: pscalar.nii
    CIFTI - Parcel Series: ptseries.nii
    CIFTI - Scalar Data Series: sdseries.nii
    CZI Image: czi
    Foci: foci, wb_foci
    Histology Slices: metaczi, meta-image
    Image Read: bmp, gif, jpeg, jpg, png, ppm
    Write: bmp, jpeg, jpg, png, ppm
    Label: label.gii
    Metric: func.gii, shape.gii
    OME-ZARR Image File: ome.zarr, ome.zarr.zip
    Palette: palette, wb_palette
    RGBA: rgba.gii
    Samples: wb_samples
    Scene: scene, wb_scene
    Specification: spec, wb_spec
    Surface: surf.gii
    Volume: nii, nii.gz
    .
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `FileInformationOutputs`).
    """
    file_information_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(FILE_INFORMATION_METADATA)
    params = execution.params(params)
    cargs = file_information_cargs(params, execution)
    ret = file_information_outputs(params, execution)
    execution.run(cargs)
    return ret


def file_information(
    data_file: str,
    only_metadata: FileInformationOnlyMetadataParamsDict | None = None,
    czi_xml: bool = False,
    czi_all_sub_blocks: bool = False,
    czi: bool = False,
    only_cifti_xml: bool = False,
    only_map_names: bool = False,
    only_number_of_maps: bool = False,
    only_step_interval: bool = False,
    no_map_info: bool = False,
    runner: Runner | None = None,
) -> FileInformationOutputs:
    """
    LIST INFORMATION ABOUT A FILE'S CONTENT.
    
    List information about the content of a data file. Only one -only option may
    be specified. The information listed when no -only option is present is
    dependent upon the type of data file.
    
    Library paths:
    /usr/lib/x86_64-linux-gnu/qt5/plugins
    /workspace/source/build/CommandLine
    
    
    File and extensions for reading and writing:
    Annotation: wb_annot
    Annotation Text Substitution: wb_annsub.csv
    Border: border, wb_border
    CIFTI - Dense: dconn.nii
    CIFTI - Dense Label: dlabel.nii
    CIFTI - Dense Parcel: dpconn.nii
    CIFTI - Dense Scalar: dscalar.nii
    CIFTI - Dense Data Series: dtseries.nii
    CIFTI - Fiber Orientations TEMPORARY: fiberTEMP.nii
    CIFTI - Fiber Trajectory TEMPORARY: trajTEMP.wbsparse
    CIFTI - Fiber Trajectory Maps: trajMaps.wbsparse
    CIFTI - Parcel: pconn.nii
    CIFTI - Parcel Dense: pdconn.nii
    CIFTI - Parcel Label: plabel.nii
    CIFTI - Parcel Scalar: pscalar.nii
    CIFTI - Parcel Series: ptseries.nii
    CIFTI - Scalar Data Series: sdseries.nii
    CZI Image: czi
    Foci: foci, wb_foci
    Histology Slices: metaczi, meta-image
    Image Read: bmp, gif, jpeg, jpg, png, ppm
    Write: bmp, jpeg, jpg, png, ppm
    Label: label.gii
    Metric: func.gii, shape.gii
    OME-ZARR Image File: ome.zarr, ome.zarr.zip
    Palette: palette, wb_palette
    RGBA: rgba.gii
    Samples: wb_samples
    Scene: scene, wb_scene
    Specification: spec, wb_spec
    Surface: surf.gii
    Volume: nii, nii.gz
    .
    
    Args:
        data_file: data file.
        only_metadata: suppress normal output, print file metadata.
        czi_xml: show XML from CZI file.
        czi_all_sub_blocks: show all sub-blocks in CZI file (may produce long\
            output).
        czi: For a CZI file, show information from the libCZI Info Command\
            instead of the Workbench CZI File.
        only_cifti_xml: suppress normal output, print the cifti xml if the file\
            type has it.
        only_map_names: suppress normal output, print the names of all maps.
        only_number_of_maps: suppress normal output, print the number of maps.
        only_step_interval: suppress normal output, print the interval between\
            maps.
        no_map_info: do not show map information for files that support maps.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `FileInformationOutputs`).
    """
    params = file_information_params(
        data_file=data_file,
        only_metadata=only_metadata,
        czi_xml=czi_xml,
        czi_all_sub_blocks=czi_all_sub_blocks,
        czi=czi,
        only_cifti_xml=only_cifti_xml,
        only_map_names=only_map_names,
        only_number_of_maps=only_number_of_maps,
        only_step_interval=only_step_interval,
        no_map_info=no_map_info,
    )
    return file_information_execute(params, runner)


__all__ = [
    "FILE_INFORMATION_METADATA",
    "FileInformationOnlyMetadataParamsDict",
    "FileInformationOnlyMetadataParamsDictTagged",
    "FileInformationOutputs",
    "FileInformationParamsDict",
    "FileInformationParamsDictTagged",
    "file_information",
    "file_information_execute",
    "file_information_only_metadata",
    "file_information_params",
]
