Skip to content

Commit 3ed8891

Browse files
authored
🔊 Add debug info command (#643)
debug info command for 1.6.x
2 parents 888b2b3 + 6444bb9 commit 3ed8891

File tree

8 files changed

+133
-20
lines changed

8 files changed

+133
-20
lines changed

.github/issue_template.md

Lines changed: 3 additions & 16 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Here you can find the recent changes to tmuxp
66

77
current
88
-------
9+
- :issue:`352` New command ``tmuxp debug-info`` for creating github issues
910
- *Insert changes/features/fixes for next release here*
1011

1112
tmuxp 1.6.1 (2020-11-07)

README.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,21 @@ You can auto confirm the prompt. In this case no preview will be shown.
177177
$ tmuxp convert --yes filename
178178
179179
180+
Debug Info
181+
---------
182+
183+
Collect system info to submit with a Github issue
184+
185+
.. code-block:: sh
186+
187+
$ tmuxp debug-info
188+
--------------------------
189+
environment:
190+
system: Linux
191+
arch: x86_64
192+
...
193+
194+
180195
Docs / Reading material
181196
-----------------------
182197

docs/cli.rst

Lines changed: 16 additions & 0 deletions
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

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ skip-string-normalization = true
33

44
[tool.poetry]
55
name = "tmuxp"
6-
version = "1.6.1"
6+
version = "1.6.2"
77
description = "tmux session manager"
88
license = "MIT"
99
authors = ["Tony Narlock <tony@git-pull.com>"]

tests/test_cli.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from tmuxp import cli, config, exc
1717
from tmuxp.cli import (
1818
command_ls,
19+
command_debug_info,
1920
get_config_dir,
2021
is_pure_name,
2122
load_workspace,
@@ -953,3 +954,24 @@ def test_ls_cli(monkeypatch, tmpdir):
953954
runner = CliRunner()
954955
cli_output = runner.invoke(command_ls).output
955956
assert cli_output == '\n'.join(stems) + '\n'
957+
958+
959+
def test_debug_info_cli(monkeypatch, tmpdir):
960+
monkeypatch.setenv('SHELL', '/bin/bash')
961+
962+
runner = CliRunner()
963+
cli_output = runner.invoke(command_debug_info).output
964+
assert 'environment' in cli_output
965+
assert 'python version' in cli_output
966+
assert 'system PATH' in cli_output
967+
assert 'tmux version' in cli_output
968+
assert 'libtmux version' in cli_output
969+
assert 'tmuxp version' in cli_output
970+
assert 'tmux path' in cli_output
971+
assert 'tmuxp path' in cli_output
972+
assert 'shell' in cli_output
973+
assert 'tmux session' in cli_output
974+
assert 'tmux windows' in cli_output
975+
assert 'tmux panes' in cli_output
976+
assert 'tmux global options' in cli_output
977+
assert 'tmux window options' in cli_output

tmuxp/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__title__ = 'tmuxp'
22
__package_name__ = 'tmuxp'
3-
__version__ = '1.6.1'
3+
__version__ = '1.6.2'
44
__description__ = 'tmux session manager'
55
__email__ = 'tony@git-pull.com'
66
__author__ = 'Tony Narlock'

tmuxp/cli.py

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,26 @@
99

1010
import logging
1111
import os
12+
import platform
1213
import sys
1314

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

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

22-
from . import config, exc, log, util
29+
from libtmux import __version__ as libtmux_version
30+
31+
from . import config, exc, log, util, __file__ as tmuxp_path
2332
from .__about__ import __version__
2433
from ._compat import PY3, PYMINOR, string_types
2534
from .workspacebuilder import WorkspaceBuilder, freeze
@@ -1054,3 +1063,66 @@ def command_ls():
10541063
if os.path.isdir(f) or ext not in VALID_CONFIG_DIR_FILE_EXTENSIONS:
10551064
continue
10561065
print(stem)
1066+
1067+
1068+
@cli.command(name='debug-info', short_help='Print out all diagnostic info')
1069+
def command_debug_info():
1070+
"""
1071+
Print debug info to submit with Issues.
1072+
"""
1073+
1074+
def prepend_tab(strings):
1075+
"""
1076+
Prepend tab to strings in list.
1077+
"""
1078+
return list(map(lambda x: '\t%s' % x, strings))
1079+
1080+
def output_break():
1081+
"""
1082+
Generate output break.
1083+
"""
1084+
return '-' * 25
1085+
1086+
def format_tmux_resp(std_resp):
1087+
"""
1088+
Format tmux command response for tmuxp stdout.
1089+
"""
1090+
return '\n'.join(
1091+
[
1092+
'\n'.join(prepend_tab(std_resp.stdout)),
1093+
click.style('\n'.join(prepend_tab(std_resp.stderr)), fg='red'),
1094+
]
1095+
)
1096+
1097+
output = [
1098+
output_break(),
1099+
'environment:\n%s'
1100+
% '\n'.join(
1101+
prepend_tab(
1102+
[
1103+
'dist: %s' % platform.platform(),
1104+
'arch: %s' % platform.machine(),
1105+
'uname: %s' % '; '.join(platform.uname()[:3]),
1106+
'version: %s' % platform.version(),
1107+
]
1108+
)
1109+
),
1110+
output_break(),
1111+
'python version: %s' % ' '.join(sys.version.split('\n')),
1112+
'system PATH: %s' % os.environ['PATH'],
1113+
'tmux version: %s' % get_version(),
1114+
'libtmux version: %s' % libtmux_version,
1115+
'tmuxp version: %s' % __version__,
1116+
'tmux path: %s' % which('tmux'),
1117+
'tmuxp path: %s' % tmuxp_path,
1118+
'shell: %s' % os.environ['SHELL'],
1119+
output_break(),
1120+
'tmux sessions:\n%s' % format_tmux_resp(tmux_cmd('list-sessions')),
1121+
'tmux windows:\n%s' % format_tmux_resp(tmux_cmd('list-windows')),
1122+
'tmux panes:\n%s' % format_tmux_resp(tmux_cmd('list-panes')),
1123+
'tmux global options:\n%s' % format_tmux_resp(tmux_cmd('show-options', '-g')),
1124+
'tmux window options:\n%s'
1125+
% format_tmux_resp(tmux_cmd('show-window-options', '-g')),
1126+
]
1127+
1128+
click.echo('\n'.join(output))

0 commit comments

Comments
 (0)