libtmux icon indicating copy to clipboard operation
libtmux copied to clipboard

Split init / exec of tmux_cmd for debuggability

Open tony opened this issue 7 years ago • 3 comments

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 avatar Nov 10 '17 01:11 tony

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.

tony avatar Nov 10 '17 01:11 tony

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (02fe5d6) 88.13% compared to head (8e00da8) 88.04%. Report is 929 commits behind head on master.

Files Patch % Lines
tests/test_common.py 80.95% 4 Missing :warning:
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     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-io avatar Nov 10 '17 04:11 codecov-io

This is very similar to SubprocessCommand (source)

tony avatar Aug 14 '22 05:08 tony