Skip to content

Commit 7f9fedf

Browse files
committed
Merge v1.6.2 (debug-info) branch 'v1.6.x' from #643
Thank you @joseph-flinn
2 parents f3a5b21 + 8858179 commit 7f9fedf

File tree

6 files changed

+135
-18
lines changed

6 files changed

+135
-18
lines changed

.github/issue_template.md

+3-16
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,10 @@
22
* For general technical questions, problems or feature requests related to the code **in this repository** file an issue.
33

44
### Step 2: Provide tmuxp details
5-
* Python version
6-
* system PATH
7-
* tmux version
8-
* tmuxp version
9-
* tmux path
10-
* tmuxp path,
11-
* libtmux version
12-
* shell
13-
* output of `tmux list-sessions`, `tmux list-windows`, `tmux list-panes`
14-
* output of `tmux show-options -g`, `tmux show-window-options -g`
15-
* output of `tmuxp freeze <SESSION_NAME>`
5+
* Include output of `tmuxp debug-info`
6+
* Include any other pertinant system info not captured
167

17-
### Step 3: Describe your environment
18-
* Architecture: _____
19-
* OS version: _____
20-
21-
### Step 4: Describe the problem:
8+
### Step 3: Describe the problem:
229
#### Steps to reproduce:
2310
1. _____
2411
2. _____

CHANGES

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ tmuxp 1.7.0a1 (2020-11-07)
2020

2121
Thank you @joseph-flinn!
2222

23+
tmuxp 1.6.2 (2020-11-08)
24+
------------------------
25+
- :issue:`643` New command ``tmuxp debug-info`` for creating github
26+
issues, fixes :issue:`352`. Thank you @joseph-flinn!
27+
2328
.. _v1.6.1:
2429

2530
tmuxp 1.6.1 (2020-11-07)

README.rst

+15
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,21 @@ Plugin System
181181
tmuxp has a plugin system to allow for custom behavior. See more about the
182182
`Plugin System`_.
183183
184+
Debug Info
185+
----------
186+
187+
Collect system info to submit with a Github issue:
188+
189+
.. code-block:: sh
190+
191+
$ tmuxp debug-info
192+
------------------
193+
environment:
194+
system: Linux
195+
arch: x86_64
196+
197+
# ... so on
198+
184199
Docs / Reading material
185200
-----------------------
186201

docs/cli.rst

+16
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,22 @@ are created, the last session is named from the terminal.
184184
185185
$ tmxup load -s <new_session_name> <filename1> ...
186186
187+
.. _cli_debug_info:
188+
189+
Debug Info
190+
----------
191+
192+
Use to collect all relevant information for submitting an issue to the project.
193+
194+
.. code-block:: bash
195+
196+
$ tmuxp debug-info
197+
--------------------------
198+
environment:
199+
system: Linux
200+
arch: x86_64
201+
...
202+
187203
.. _cli_import:
188204

189205
Import

tests/test_cli.py

+22
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from tmuxp import cli, config, exc
1919
from tmuxp.cli import (
2020
_reattach,
21+
command_debug_info,
2122
command_ls,
2223
get_config_dir,
2324
is_pure_name,
@@ -1058,3 +1059,24 @@ def test_reattach_plugins(server):
10581059
proc = builder.session.cmd('display-message', '-p', "'#S'")
10591060

10601061
assert proc.stdout[0] == "'plugin_test_r'"
1062+
1063+
1064+
def test_debug_info_cli(monkeypatch, tmpdir):
1065+
monkeypatch.setenv('SHELL', '/bin/bash')
1066+
1067+
runner = CliRunner()
1068+
cli_output = runner.invoke(command_debug_info).output
1069+
assert 'environment' in cli_output
1070+
assert 'python version' in cli_output
1071+
assert 'system PATH' in cli_output
1072+
assert 'tmux version' in cli_output
1073+
assert 'libtmux version' in cli_output
1074+
assert 'tmuxp version' in cli_output
1075+
assert 'tmux path' in cli_output
1076+
assert 'tmuxp path' in cli_output
1077+
assert 'shell' in cli_output
1078+
assert 'tmux session' in cli_output
1079+
assert 'tmux windows' in cli_output
1080+
assert 'tmux panes' in cli_output
1081+
assert 'tmux global options' in cli_output
1082+
assert 'tmux window options' in cli_output

tmuxp/cli.py

+74-2
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,26 @@
1010
import importlib
1111
import logging
1212
import os
13+
import platform
1314
import sys
1415

1516
import click
1617
import kaptan
1718
from click.exceptions import FileError
1819

19-
from libtmux.common import has_gte_version, has_minimum_version, which
20+
from libtmux.common import (
21+
has_gte_version,
22+
has_minimum_version,
23+
which,
24+
get_version,
25+
tmux_cmd,
26+
)
2027
from libtmux.exc import TmuxCommandNotFound
2128
from libtmux.server import Server
2229

23-
from . import config, exc, log, util
30+
from libtmux import __version__ as libtmux_version
31+
32+
from . import config, exc, log, util, __file__ as tmuxp_path
2433
from .__about__ import __version__
2534
from ._compat import PY3, PYMINOR, string_types
2635
from .workspacebuilder import WorkspaceBuilder, freeze
@@ -1100,3 +1109,66 @@ def command_ls():
11001109
if os.path.isdir(f) or ext not in VALID_CONFIG_DIR_FILE_EXTENSIONS:
11011110
continue
11021111
print(stem)
1112+
1113+
1114+
@cli.command(name='debug-info', short_help='Print out all diagnostic info')
1115+
def command_debug_info():
1116+
"""
1117+
Print debug info to submit with Issues.
1118+
"""
1119+
1120+
def prepend_tab(strings):
1121+
"""
1122+
Prepend tab to strings in list.
1123+
"""
1124+
return list(map(lambda x: '\t%s' % x, strings))
1125+
1126+
def output_break():
1127+
"""
1128+
Generate output break.
1129+
"""
1130+
return '-' * 25
1131+
1132+
def format_tmux_resp(std_resp):
1133+
"""
1134+
Format tmux command response for tmuxp stdout.
1135+
"""
1136+
return '\n'.join(
1137+
[
1138+
'\n'.join(prepend_tab(std_resp.stdout)),
1139+
click.style('\n'.join(prepend_tab(std_resp.stderr)), fg='red'),
1140+
]
1141+
)
1142+
1143+
output = [
1144+
output_break(),
1145+
'environment:\n%s'
1146+
% '\n'.join(
1147+
prepend_tab(
1148+
[
1149+
'dist: %s' % platform.platform(),
1150+
'arch: %s' % platform.machine(),
1151+
'uname: %s' % '; '.join(platform.uname()[:3]),
1152+
'version: %s' % platform.version(),
1153+
]
1154+
)
1155+
),
1156+
output_break(),
1157+
'python version: %s' % ' '.join(sys.version.split('\n')),
1158+
'system PATH: %s' % os.environ['PATH'],
1159+
'tmux version: %s' % get_version(),
1160+
'libtmux version: %s' % libtmux_version,
1161+
'tmuxp version: %s' % __version__,
1162+
'tmux path: %s' % which('tmux'),
1163+
'tmuxp path: %s' % tmuxp_path,
1164+
'shell: %s' % os.environ['SHELL'],
1165+
output_break(),
1166+
'tmux sessions:\n%s' % format_tmux_resp(tmux_cmd('list-sessions')),
1167+
'tmux windows:\n%s' % format_tmux_resp(tmux_cmd('list-windows')),
1168+
'tmux panes:\n%s' % format_tmux_resp(tmux_cmd('list-panes')),
1169+
'tmux global options:\n%s' % format_tmux_resp(tmux_cmd('show-options', '-g')),
1170+
'tmux window options:\n%s'
1171+
% format_tmux_resp(tmux_cmd('show-window-options', '-g')),
1172+
]
1173+
1174+
click.echo('\n'.join(output))

0 commit comments

Comments
 (0)