Skip to content

Commit 0de4483

Browse files
committed
!squash WIP Session.cmd warning for target kw
1 parent 42dcfc7 commit 0de4483

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/libtmux/session.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,13 @@ def panes(self) -> QueryList["Pane"]:
141141
#
142142
# Command
143143
#
144-
def cmd(self, cmd: str, *args: t.Any) -> tmux_cmd:
144+
def cmd(
145+
self, cmd: str, *args: t.Any, target: t.Optional[t.Union[str, int]] = None
146+
) -> tmux_cmd:
145147
"""Execute tmux subcommand within session context.
146148
147-
Automatically adds ``-t`` for object's session ID to the command. Pass ``-t``
148-
in args to override.
149+
Automatically binds target by adding ``-t`` for object's session ID to the
150+
command. Pass ``target`` to keyword arguments to override.
149151
150152
Examples
151153
--------
@@ -158,6 +160,11 @@ def cmd(self, cmd: str, *args: t.Any) -> tmux_cmd:
158160
... 'new-window', '-P', '-F#{window_id}').stdout[0], server=session.server)
159161
Window(@... ...:..., Session($1 libtmux_...))
160162
163+
Parameters
164+
----------
165+
target : str, optional
166+
Optional custom target override. By default, the target is the session ID.
167+
161168
Returns
162169
-------
163170
:meth:`server.cmd`
@@ -170,6 +177,11 @@ def cmd(self, cmd: str, *args: t.Any) -> tmux_cmd:
170177
"""
171178
# if -t is not set in any arg yet
172179
if not any("-t" in str(x) for x in args):
180+
# warnings.warn(
181+
# "Use `target=...` instead of passing `-t` as an argument.",
182+
# category=DeprecationWarning,
183+
# stacklevel=2,
184+
# )
173185
# insert -t immediately after 1st arg, as per tmux format
174186
new_args: t.Tuple[str, ...] = ()
175187
assert isinstance(self.session_id, str)

0 commit comments

Comments
 (0)