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

import typing
import pathlib
from styxdefs import *
import dataclasses

FILE_TOOL_METADATA = Metadata(
    id="a338b51bc00f0441446c6ca843266cef70008a68.boutiques",
    name="file_tool",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class FileToolOutputs(typing.NamedTuple):
    """
    Output object returned when calling `file_tool(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    modified_file: OutputPathType | None
    """The modified output file"""


def file_tool(
    infiles: list[InputPathType],
    help_: bool = False,
    version: bool = False,
    hist: bool = False,
    debug: float | None = None,
    ge_all: bool = False,
    ge_header: bool = False,
    ge_extras: bool = False,
    ge_uv17: bool = False,
    ge_run: bool = False,
    ge_off: bool = False,
    ge4_all: bool = False,
    ge4_image: bool = False,
    ge4_series: bool = False,
    ge4_study: bool = False,
    def_ana_hdr: bool = False,
    diff_ana_hdrs: bool = False,
    disp_ana_hdr: bool = False,
    hex_: bool = False,
    mod_ana_hdr: bool = False,
    mod_field: str | None = None,
    prefix: str | None = None,
    overwrite: bool = False,
    show_bad_all: bool = False,
    show_bad_backslash: bool = False,
    show_bad_char: bool = False,
    show_file_type: bool = False,
    fix_rich_quotes: str | None = None,
    test: bool = False,
    length: float | None = None,
    mod_data: str | None = None,
    mod_type: str | None = None,
    offset: float | None = None,
    quiet: bool = False,
    disp_hex: bool = False,
    disp_hex1: bool = False,
    disp_hex2: bool = False,
    disp_hex4: bool = False,
    disp_int2: bool = False,
    disp_int4: bool = False,
    disp_real4: bool = False,
    swap_bytes: bool = False,
    runner: Runner | None = None,
) -> FileToolOutputs:
    """
    Program to display or modify sections of a file.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        infiles: Specify input files to display or modify.
        help_: Show help information.
        version: Show version information.
        hist: Show the program's modification history.
        debug: Print extra info along the way, default is 0, max is 2.
        ge_all: Display GE header and extras info.
        ge_header: Display GE header info.
        ge_extras: Display extra GE image info.
        ge_uv17: Display the value of uv17 (the run #).
        ge_run: Display the value of uv17 (the run #).
        ge_off: Display file offsets for various fields.
        ge4_all: Display GEMS 4.x series and image headers.
        ge4_image: Display GEMS 4.x image header.
        ge4_series: Display GEMS 4.x series header.
        ge4_study: Display GEMS 4.x study header.
        def_ana_hdr: Display the definition of an ANALYZE header.
        diff_ana_hdrs: Display field differences between 2 headers.
        disp_ana_hdr: Display ANALYZE headers.
        hex_: Display field values in hexadecimal.
        mod_ana_hdr: Modify ANALYZE headers.
        mod_field: Specify a field and value(s) to modify.
        prefix: Specify an output filename.
        overwrite: Specify to overwrite the input file(s).
        show_bad_all: Show lines with whitespace after '\\'.
        show_bad_backslash: Show lines with whitespace after '\\'.
        show_bad_char: Show any non-printable characters.
        show_file_type: Print file type of UNIX, Mac or DOS.
        fix_rich_quotes: Replace rich-text quotes with ASCII.
        test: Short for -show_bad_all. Check script files for known issues.
        length: Specify the number of bytes to print/modify.
        mod_data: Specify a string to modify the data to.
        mod_type: Specify the data type to write to the file.
        offset: Specify the offset into each file.
        quiet: Do not output header information.
        disp_hex: Display bytes in hex.
        disp_hex1: Display bytes in hex.
        disp_hex2: Display 2-byte integers in hex.
        disp_hex4: Display 4-byte integers in hex.
        disp_int2: Display 2-byte integers.
        disp_int4: Display 4-byte integers.
        disp_real4: Display 4-byte real numbers.
        swap_bytes: Use byte-swapping on numbers.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `FileToolOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(FILE_TOOL_METADATA)
    cargs = []
    cargs.append("file_tool")
    if help_:
        cargs.append("-help")
    if version:
        cargs.append("-version")
    if hist:
        cargs.append("-hist")
    if debug is not None:
        cargs.extend([
            "-debug",
            str(debug)
        ])
    cargs.extend([
        "-infiles",
        *[execution.input_file(f) for f in infiles]
    ])
    if ge_all:
        cargs.append("-ge_all")
    if ge_header:
        cargs.append("-ge_header")
    if ge_extras:
        cargs.append("-ge_extras")
    if ge_uv17:
        cargs.append("-ge_uv17")
    if ge_run:
        cargs.append("-ge_run")
    if ge_off:
        cargs.append("-ge_off")
    if ge4_all:
        cargs.append("-ge4_all")
    if ge4_image:
        cargs.append("-ge4_image")
    if ge4_series:
        cargs.append("-ge4_series")
    if ge4_study:
        cargs.append("-ge4_study")
    if def_ana_hdr:
        cargs.append("-def_ana_hdr")
    if diff_ana_hdrs:
        cargs.append("-diff_ana_hdrs")
    if disp_ana_hdr:
        cargs.append("-disp_ana_hdr")
    if hex_:
        cargs.append("-hex")
    if mod_ana_hdr:
        cargs.append("-mod_ana_hdr")
    if mod_field is not None:
        cargs.extend([
            "-mod_field",
            mod_field
        ])
    if prefix is not None:
        cargs.extend([
            "-prefix",
            prefix
        ])
    if overwrite:
        cargs.append("-overwrite")
    if show_bad_all:
        cargs.append("-show_bad_all")
    if show_bad_backslash:
        cargs.append("-show_bad_backslash")
    if show_bad_char:
        cargs.append("-show_bad_char")
    if show_file_type:
        cargs.append("-show_file_type")
    if fix_rich_quotes is not None:
        cargs.extend([
            "-fix_rich_quotes",
            fix_rich_quotes
        ])
    if test:
        cargs.append("-test")
    if length is not None:
        cargs.extend([
            "-length",
            str(length)
        ])
    if mod_data is not None:
        cargs.extend([
            "-mod_data",
            mod_data
        ])
    if mod_type is not None:
        cargs.extend([
            "-mod_type",
            mod_type
        ])
    if offset is not None:
        cargs.extend([
            "-offset",
            str(offset)
        ])
    if quiet:
        cargs.append("-quiet")
    if disp_hex:
        cargs.append("-disp_hex")
    if disp_hex1:
        cargs.append("-disp_hex1")
    if disp_hex2:
        cargs.append("-disp_hex2")
    if disp_hex4:
        cargs.append("-disp_hex4")
    if disp_int2:
        cargs.append("-disp_int2")
    if disp_int4:
        cargs.append("-disp_int4")
    if disp_real4:
        cargs.append("-disp_real4")
    if swap_bytes:
        cargs.append("-swap_bytes")
    ret = FileToolOutputs(
        root=execution.output_file("."),
        modified_file=execution.output_file(prefix) if (prefix is not None) else None,
    )
    execution.run(cargs)
    return ret


__all__ = [
    "FILE_TOOL_METADATA",
    "FileToolOutputs",
    "file_tool",
]
