Skip to content

Commit 9081cc4

Browse files
committed
Server.acmd: WIP
1 parent df7df77 commit 9081cc4

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

src/libtmux/server.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -258,32 +258,48 @@ async def acmd(
258258
259259
Examples
260260
--------
261-
>>> server.acmd('display-message', 'hi')
262-
<libtmux.common.AsyncTmuxCmd object at ...>
261+
>>> import asyncio
262+
>>> server = Server(socket_name="test")
263+
>>> async def test_acmd():
264+
... result = await server.acmd('display-message', 'hi')
265+
... print(result.stdout)
266+
>>> asyncio.run(test_acmd())
267+
[]
263268
264269
New session:
265270
266-
>>> server.acmd('new-session', '-d', '-P', '-F#{session_id}').stdout[0]
267-
'$2'
268-
269-
>>> session.acmd('new-window', '-P').stdout[0]
270-
'libtmux...:2.0'
271+
>>> async def test_new_session():
272+
... result = await server.acmd('new-session', '-d', '-P', '-F#{session_id}')
273+
... print(result.stdout[0])
274+
>>> asyncio.run(test_new_session())
275+
$...
271276
272277
Output of `tmux -L ... new-window -P -F#{window_id}` to a `Window` object:
273278
274-
>>> Window.from_window_id(window_id=await session.acmd(
275-
... 'new-window', '-P', '-F#{window_id}').stdout[0], server=session.server)
276-
Window(@4 3:..., Session($1 libtmux_...))
279+
>>> async def test_new_window():
280+
... result = await server.acmd('new-window', '-P', '-F#{window_id}')
281+
... window_id = result.stdout[0]
282+
... window = Window.from_window_id(window_id=window_id, server=server)
283+
... print(window)
284+
>>> asyncio.run(test_new_window())
285+
Window(@... ...:..., Session($... libtmux_...))
277286
278287
Create a pane from a window:
279288
280-
>>> window.acmd('split-window', '-P', '-F#{pane_id}').stdout[0]
281-
'%5'
289+
>>> async def test_split_window():
290+
... result = await server.acmd('split-window', '-P', '-F#{pane_id}')
291+
... print(result.stdout[0])
292+
>>> asyncio.run(test_split_window())
293+
%...
282294
283295
Output of `tmux -L ... split-window -P -F#{pane_id}` to a `Pane` object:
284296
285-
>>> Pane.from_pane_id(pane_id=window.cmd(
286-
... 'split-window', '-P', '-F#{pane_id}').stdout[0], server=window.server)
297+
>>> async def test_pane():
298+
... result = await server.acmd('split-window', '-P', '-F#{pane_id}')
299+
... pane_id = result.stdout[0]
300+
... pane = Pane.from_pane_id(pane_id=pane_id, server=server)
301+
... print(pane)
302+
>>> asyncio.run(test_pane())
287303
Pane(%... Window(@... ...:..., Session($1 libtmux_...)))
288304
289305
Parameters

0 commit comments

Comments
 (0)