diff --git a/parse_formats.py b/parse_formats.py index 8601b2a..499a0fb 100755 --- a/parse_formats.py +++ b/parse_formats.py @@ -3,6 +3,7 @@ import dataclasses import pathlib import re +import textwrap import typing as t cwd = pathlib.Path(__file__).parent @@ -72,8 +73,40 @@ def run() -> int: for manual in version_map.values(): print(f"tmux {manual.version}") - formats = ", ".join([format.variable_name for format in manual.formats]) - print(f" Formats: {formats}") + + # Array + formats = ", ".join([f'"{format.variable_name}"' for format in manual.formats]) + print(f" Formats: [{formats}]") + + # Dataclass + print( + textwrap.dedent( + f""" +@dataclasses.dataclass +class TmuxObject: + """ + + "\n ".join( + [ + f"{format.variable_name}: str | None = None" + for format in manual.formats + ] + ) + ) + ) + + raw_formats = [format.variable_name for format in manual.formats] + + if manual.version == "3.0a": + try: + assert "pane_title" in raw_formats + except AssertionError: + print("Should have pane title") + raise + elif manual.version == "3.3": + try: + assert "pane_title" not in raw_formats + except AssertionError: + print("Should not have pane_title") return 0