Skip to content

Commit 1c46c77

Browse files
committed
options(feat[show_options]): Add public show_options() method
why: CHANGES documented Window.show_options() as replacement for show_window_options(), but only private _show_options() existed. what: - Add show_options() public method to OptionsMixin as thin wrapper - Update Window.show_window_options() deprecation to reference show_options() - Add doctest examples for show_options()
1 parent ec4752f commit 1c46c77

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

src/libtmux/options.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,52 @@ def _show_options(
939939

940940
return t.cast("ExplodedComplexUntypedOptionsDict", output_exploded)
941941

942+
def show_options(
943+
self,
944+
global_: bool = False,
945+
scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE,
946+
include_hooks: bool | None = None,
947+
include_inherited: bool | None = None,
948+
) -> ExplodedComplexUntypedOptionsDict:
949+
"""Return all options for the target.
950+
951+
Parameters
952+
----------
953+
global_ : bool, optional
954+
Pass ``-g`` flag for global options, default False.
955+
scope : OptionScope | _DefaultOptionScope | None, optional
956+
Option scope (Server/Session/Window/Pane), defaults to object's scope.
957+
include_hooks : bool, optional
958+
Include hook options (``-H`` flag).
959+
include_inherited : bool, optional
960+
Include inherited options (``-A`` flag).
961+
962+
Returns
963+
-------
964+
ExplodedComplexUntypedOptionsDict
965+
Dictionary with all options, arrays exploded and values converted.
966+
967+
Raises
968+
------
969+
:exc:`exc.OptionError`, :exc:`exc.UnknownOption`,
970+
:exc:`exc.InvalidOption`, :exc:`exc.AmbiguousOption`
971+
972+
Examples
973+
--------
974+
>>> options = server.show_options()
975+
>>> isinstance(options, dict)
976+
True
977+
978+
>>> 'buffer-limit' in options
979+
True
980+
"""
981+
return self._show_options(
982+
global_=global_,
983+
scope=scope,
984+
include_hooks=include_hooks,
985+
include_inherited=include_inherited,
986+
)
987+
942988
def _show_option_raw(
943989
self,
944990
option: str,

src/libtmux/window.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -884,20 +884,20 @@ def set_window_option(
884884
return self.set_option(option=option, value=value)
885885

886886
def show_window_options(self, g: bool | None = False) -> WindowOptionDict:
887-
"""Show options for tmux window. Deprecated by :meth:`Window._show_options()`.
887+
"""Show options for tmux window. Deprecated by :meth:`Window.show_options()`.
888888
889889
.. deprecated:: 0.26
890890
891-
Deprecated by :meth:`Window._show_options()`.
891+
Deprecated by :meth:`Window.show_options()`.
892892
893893
"""
894894
warnings.warn(
895895
"Window.show_window_options() is deprecated",
896896
category=DeprecationWarning,
897897
stacklevel=2,
898898
)
899-
return self._show_options(
900-
g=g,
899+
return self.show_options(
900+
global_=g or False,
901901
scope=OptionScope.Window,
902902
)
903903

0 commit comments

Comments
 (0)