Skip to content

Commit be42841

Browse files
committed
feat: fill missing flag gaps on recently added commands
why: Flag audit found useful parameters that were not exposed on commands added in the parity work. what: - unbind_key: add all_keys (-a), quiet (-q) parameters - source_file: add parse_only (-n), verbose (-v) parameters - display_popup: add x (-x), y (-y) position parameters - detach_client: add shell_command (-E) parameter
1 parent 8ab9634 commit be42841

3 files changed

Lines changed: 47 additions & 4 deletions

File tree

src/libtmux/pane.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,8 @@ def display_popup(
11471147
close_on_success: bool | None = None,
11481148
width: int | str | None = None,
11491149
height: int | str | None = None,
1150+
x: int | str | None = None,
1151+
y: int | str | None = None,
11501152
start_directory: StrPath | None = None,
11511153
title: str | None = None,
11521154
border_lines: str | None = None,
@@ -1171,6 +1173,10 @@ def display_popup(
11711173
Popup width (``-w`` flag).
11721174
height : int or str, optional
11731175
Popup height (``-h`` flag).
1176+
x : int or str, optional
1177+
Popup x position (``-x`` flag).
1178+
y : int or str, optional
1179+
Popup y position (``-y`` flag).
11741180
start_directory : str or PathLike, optional
11751181
Working directory (``-d`` flag).
11761182
title : str, optional
@@ -1207,6 +1213,12 @@ def display_popup(
12071213
if height is not None:
12081214
tmux_args += ("-h", str(height))
12091215

1216+
if x is not None:
1217+
tmux_args += ("-x", str(x))
1218+
1219+
if y is not None:
1220+
tmux_args += ("-y", str(y))
1221+
12101222
if start_directory is not None:
12111223
start_path = pathlib.Path(start_directory).expanduser()
12121224
tmux_args += ("-d", str(start_path))

src/libtmux/server.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,18 +577,24 @@ def bind_key(
577577

578578
def unbind_key(
579579
self,
580-
key: str,
580+
key: str | None = None,
581581
*,
582582
key_table: str | None = None,
583+
all_keys: bool | None = None,
584+
quiet: bool | None = None,
583585
) -> None:
584586
"""Unbind a key via ``$ tmux unbind-key``.
585587
586588
Parameters
587589
----------
588-
key : str
589-
Key to unbind.
590+
key : str, optional
591+
Key to unbind. Required unless *all_keys* is True.
590592
key_table : str, optional
591593
Key table (``-T`` flag). Defaults to ``prefix``.
594+
all_keys : bool, optional
595+
Unbind all keys (``-a`` flag).
596+
quiet : bool, optional
597+
Suppress errors for missing bindings (``-q`` flag).
592598
593599
Examples
594600
--------
@@ -597,10 +603,17 @@ def unbind_key(
597603
"""
598604
tmux_args: tuple[str, ...] = ()
599605

606+
if all_keys:
607+
tmux_args += ("-a",)
608+
609+
if quiet:
610+
tmux_args += ("-q",)
611+
600612
if key_table is not None:
601613
tmux_args += ("-T", key_table)
602614

603-
tmux_args += (key,)
615+
if key is not None:
616+
tmux_args += (key,)
604617

605618
proc = self.cmd("unbind-key", *tmux_args)
606619

@@ -1154,6 +1167,8 @@ def source_file(
11541167
path: StrPath,
11551168
*,
11561169
quiet: bool | None = None,
1170+
parse_only: bool | None = None,
1171+
verbose: bool | None = None,
11571172
) -> None:
11581173
"""Source a tmux configuration file via ``$ tmux source-file``.
11591174
@@ -1163,6 +1178,10 @@ def source_file(
11631178
Path to the configuration file.
11641179
quiet : bool, optional
11651180
Suppress errors for missing files (``-q`` flag).
1181+
parse_only : bool, optional
1182+
Check syntax only, do not execute (``-n`` flag).
1183+
verbose : bool, optional
1184+
Show parsed commands (``-v`` flag).
11661185
11671186
Examples
11681187
--------
@@ -1176,6 +1195,12 @@ def source_file(
11761195
if quiet:
11771196
tmux_args += ("-q",)
11781197

1198+
if parse_only:
1199+
tmux_args += ("-n",)
1200+
1201+
if verbose:
1202+
tmux_args += ("-v",)
1203+
11791204
tmux_args += (str(pathlib.Path(path).expanduser()),)
11801205

11811206
proc = self.cmd("source-file", *tmux_args)

src/libtmux/session.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ def detach_client(
262262
*,
263263
target_client: str | None = None,
264264
all_clients: bool | None = None,
265+
shell_command: str | None = None,
265266
) -> None:
266267
"""Detach clients from this session via ``$ tmux detach-client``.
267268
@@ -272,6 +273,8 @@ def detach_client(
272273
the most recently active client.
273274
all_clients : bool, optional
274275
Detach all clients attached to this session (``-a`` flag).
276+
shell_command : str, optional
277+
Run a shell command after detaching (``-E`` flag).
275278
276279
Examples
277280
--------
@@ -283,6 +286,9 @@ def detach_client(
283286
if all_clients:
284287
tmux_args += ("-a",)
285288

289+
if shell_command is not None:
290+
tmux_args += ("-E", shell_command)
291+
286292
if target_client is not None:
287293
tmux_args += ("-t", target_client)
288294

0 commit comments

Comments
 (0)