Skip to content

Commit d8b0cca

Browse files
committed
refactor!(show(_window)_options): Remove item lookups
Use show(_window_option)(option:str) instead.
1 parent f606a42 commit d8b0cca

File tree

4 files changed

+11
-22
lines changed

4 files changed

+11
-22
lines changed

libtmux/session.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def set_option(self, option, value, _global=False):
421421
if isinstance(proc.stderr, list) and len(proc.stderr):
422422
handle_option_error(proc.stderr[0])
423423

424-
def show_options(self, option=None, _global=False):
424+
def show_options(self, _global=False):
425425
"""
426426
Return a dict of options for the window.
427427
@@ -430,9 +430,6 @@ def show_options(self, option=None, _global=False):
430430
431431
Parameters
432432
----------
433-
option : str, optional
434-
name of option, e.g. 'visual-silence'. Defaults to None, which
435-
returns all options.
436433
_global : bool, optional
437434
Pass ``-g`` flag for global variable (server-wide)
438435
@@ -450,11 +447,8 @@ def show_options(self, option=None, _global=False):
450447
if _global:
451448
tmux_args += ("-g",)
452449

453-
if option:
454-
return self.show_option(option, _global=_global)
455-
else:
456-
tmux_args += ("show-options",)
457-
session_options = self.cmd(*tmux_args).stdout
450+
tmux_args += ("show-options",)
451+
session_options = self.cmd(*tmux_args).stdout
458452

459453
session_options = [tuple(item.split(" ")) for item in session_options]
460454

libtmux/window.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def set_window_option(self, option, value):
193193
if isinstance(cmd.stderr, list) and len(cmd.stderr):
194194
handle_option_error(cmd.stderr[0])
195195

196-
def show_window_options(self, option=None, g=False):
196+
def show_window_options(self, g=False):
197197
"""
198198
Return a dict of options for the window.
199199
@@ -202,8 +202,6 @@ def show_window_options(self, option=None, g=False):
202202
203203
Parameters
204204
----------
205-
option : str, optional
206-
show a single option.
207205
g : str, optional
208206
Pass ``-g`` flag for global variable, default False.
209207
@@ -217,11 +215,8 @@ def show_window_options(self, option=None, g=False):
217215
if g:
218216
tmux_args += ("-g",)
219217

220-
if option:
221-
return self.show_window_option(option, g=g)
222-
else:
223-
tmux_args += ("show-window-options",)
224-
cmd = self.cmd(*tmux_args).stdout
218+
tmux_args += ("show-window-options",)
219+
cmd = self.cmd(*tmux_args).stdout
225220

226221
# The shlex.split function splits the args at spaces, while also
227222
# retaining quoted sub-strings.

tests/test_session.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ def test_set_show_options_single(session):
108108
"""Set option then Session.show_options(key)."""
109109

110110
session.set_option("history-limit", 20)
111-
assert session.show_options("history-limit") == 20
111+
assert session.show_option("history-limit") == 20
112112

113113
session.set_option("history-limit", 40)
114-
assert session.show_options("history-limit") == 40
114+
assert session.show_option("history-limit") == 40
115115

116116
assert session.show_options()["history-limit"] == 40
117117

tests/test_window.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,15 @@ def test_set_show_window_options(session):
184184
window = session.new_window(window_name="test_window")
185185

186186
window.set_window_option("main-pane-height", 20)
187-
assert window.show_window_options("main-pane-height") == 20
187+
assert window.show_window_option("main-pane-height") == 20
188188

189189
window.set_window_option("main-pane-height", 40)
190-
assert window.show_window_options("main-pane-height") == 40
190+
assert window.show_window_option("main-pane-height") == 40
191191
assert window.show_window_options()["main-pane-height"] == 40
192192

193193
if has_gte_version("2.3"):
194194
window.set_window_option("pane-border-format", " #P ")
195-
assert window.show_window_options("pane-border-format") == " #P "
195+
assert window.show_window_option("pane-border-format") == " #P "
196196

197197

198198
def test_empty_window_option_returns_None(session):

0 commit comments

Comments
 (0)