Skip to content

Split init / exec of tmux_cmd for debuggability - #79

Closed
tony wants to merge 2 commits into
masterfrom
tmux-cmd-execute
Closed

Split init / exec of tmux_cmd for debuggability#79
tony wants to merge 2 commits into
masterfrom
tmux-cmd-execute

Conversation

@tony

@tony tony commented Nov 10, 2017

Copy link
Copy Markdown
Member

Edit 2022-08-14 by @tony : This is very similar to SubprocessCommand (source)

tmux_cmd initialization composes the command

the command will be available in the instance attribute .cmd

.execute() instance method will run tmux_cmd

See Server.cmd for example of new usage

Related #77

@tony

tony commented Nov 10, 2017

Copy link
Copy Markdown
Member Author

This, as of c9598fb doesn't touch any of the Server/Session/Window/Pane .cmd method API's.

As a second part of this, I may add more things to split introspection of commands.

For instance:

  • Renaming tmux_cmd to TmuxCommand

  • Documenting how they are composed and can be configured, and why/how it's differs from standard library subprocess

  • Methods in Tmux objects, e.g. attach_session() may have a way to return the pure TmuxCommand object (and therefore preview the command generated, including the valuable target information (-t))

  • as a way the above could be implemented, it may be via adding methods like _attach_session() that return TmuxCommand and having attach_session wrap them and keep normal behavior

  • Another thing to consider is to break api's by requiring .execute() be ran to execute commands, and return TmuxCommand by default

  • BUT, allow for chaining commands. e.g., session.attached_window.set_window_option('main-pane-height', 50).select_layout('main-horizontal').execute(), this would give the equivalent to chaining commands with semicolons. This could substantially speed things up by allowing for composability with commands.

@codecov-io

codecov-io commented Nov 10, 2017

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.04%. Comparing base (02fe5d6) to head (8e00da8).
⚠️ Report is 1896 commits behind head on master.

Files with missing lines Patch % Lines
tests/test_common.py 80.95% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #79      +/-   ##
==========================================
- Coverage   88.13%   88.04%   -0.09%     
==========================================
  Files          15       15              
  Lines        1500     1523      +23     
==========================================
+ Hits         1322     1341      +19     
- Misses        178      182       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

tony added 2 commits April 9, 2022 11:38
tmux_cmd initialization composes the command

the command will be available in the instance attribute
.cmd

.execute() instance method will run tmux_cmd

see Server.cmd for example of new usage

Related #77
@tony
tony force-pushed the tmux-cmd-execute branch from 1c8f8ef to 8e00da8 Compare April 9, 2022 16:39
@tony
tony force-pushed the master branch 2 times, most recently from bb68b70 to d6ab13b Compare July 14, 2022 10:33
@tony

tony commented Aug 14, 2022

Copy link
Copy Markdown
Member Author

This is very similar to SubprocessCommand (source)

@tony

tony commented Apr 26, 2026

Copy link
Copy Markdown
Member Author

Closing as obsolete. This PR (Sep 2021) split tmux_cmd.__init__ from execution to enable better debuggability via a new TmuxCommand class. The implementation predates the src/ layout migration and references libtmux/common.py and libtmux/server.py directly — both files have since been moved to src/libtmux/, producing "modify/delete" conflicts on every change.

The underlying goal — separating tmux command construction from execution for debuggability — is still valuable, but the implementation needs to be redone against the current code structure. Master has since added structured logging via extra={"tmux_cmd": shlex.join(cmd), "tmux_exit_code": ...} (see src/libtmux/common.py:264) which already provides much of the debuggability this PR was after.

Confirmed during a 2026-04-26 batch rebase audit.

@tony tony closed this Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants